Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Building Apps for Android Auto

37fbf83b7d45711e41e774e29fed710e?s=47 Arnav Gupta
September 16, 2016

Building Apps for Android Auto

37fbf83b7d45711e41e774e29fed710e?s=128

Arnav Gupta

September 16, 2016
Tweet

More Decks by Arnav Gupta

Other Decks in Technology

Transcript

  1. Android Everywhere Your watch, your TV, your car, you fridge

    – the green robot is everywhere
  2. . . . and soon on your toaster Well .

    . . Maybe quite not yet
  3. Possibilities ? ? ?

  4. Chrysler Jeep Hack Wired Magazine, July 2015 Charlie Miller and

    Chris Valasek Hacked a Chrysler Jeep and took control of steering and throttle. July, 2015 (Not using Android Auto)
  5. None
  6. Well ok, it’s not that bad yet.

  7. Android Auto Arnav Gupta

  8. Android Auto Onboarding Process

  9. Android Auto Onboarding Process

  10. Android Auto Onboarding Process

  11. Android Auto Onboarding Process

  12. Android Auto Onboarding Process

  13. Android Auto Basic UI Components Open Maps

  14. Android Auto Basic UI Components Open Maps Open Dialer

  15. Android Auto Basic UI Components Open Maps Open Dialer Home/Notifications

  16. Android Auto Basic UI Components Open Maps Open Dialer Home/Notifications

    Music
  17. Android Auto Basic UI Components Open Maps Open Dialer Home/Notifications

    Music Back to Dash
  18. Android Auto Architecture Head Unit Screen

  19. Android Auto Architecture Audio Head Unit Screen

  20. Android Auto Architecture OBD CAN Audio Head Unit Screen

  21. Android Auto Architecture OBD CAN Audio Head Unit Screen Touch

    + Keys
  22. Android Auto Architecture Smartphone OBD CAN Audio Head Unit Screen

    Touch + Keys
  23. Android Auto Architecture Smartphone OBD CAN Rendered Screen Audio Head

    Unit Screen Touch + Keys
  24. Android Auto Architecture Smartphone OBD CAN Sensor | Touchpoint Rendered

    Screen Audio Head Unit Screen Touch + Keys
  25. Building Apps for Android Auto š Right now – only

    two types of Apps : š Audio Apps – Playback to car’s audio system š Messaging Apps – Text communication using voice commands š Android Auto v1 Does not have OBD/CAN bus data available in an API š Cannot control anything other than audio/video output for now
  26. Building Apps for Android Auto š targetSdkVersion >= 21 š

    minSdkVersion >= 21 š Does NOT work with Lollipop phones š Needs Android v4 Support Library
  27. Automotive Description XML <automotiveApp> <uses name="media" /> </automotiveApp>

  28. Add meta to Manifest <meta-data android:name="com.google.android.gms.car.application" android:resource="@xml/automotive_app_desc" />

  29. Add an Icon <meta-data android:name="com.google.android.gms.car.notification.Sm allIcon" android:resource="@drawable/ic_notification" />

  30. Designing for Android Auto Upside-down approach. Keep the user away

  31. Designing for Android Auto š Simple UI š Large buttons

    š Max depth = 6
  32. Designing for Android Auto š Simple UI š Large buttons

    š Max depth = 6 š No ”BACK” button
  33. Designing for Android Auto š Simple UI š Large buttons

    š Max depth = 6 š No ”BACK” button
  34. Distraction Free Design š More options = more car accidents

    š Small buttons = more accidents š Low contrast = more accidents š Scrolling = more accidents š Video/Picture ads = u kidding bro ?
  35. The navigation activity bar

  36. The navigation activity bar š Buttons – š Navigation š

    Communication š Home š Media š Car Dash š Single tap = default app, Double tap = optional apps
  37. Google Now Demand Layer

  38. The notification home screen

  39. Anatomy of Home Cards

  40. Nav Drawers – It’s in landscape now

  41. Nav Drawers - Categories and Icons

  42. Notifications

  43. Testing Android Auto š Buy a Rs. 14 lakh car

    you cheapass !!!
  44. Testing Android Auto š Buy a Rs. 14 lakh car

    you cheapass !!!
  45. Testing Android Auto š Buy a Rs. 14 lakh car

    you cheapass !!!
  46. Testing Android Auto š Install the Android “Desktop Head Unit

    Simulator” in Android SDK š Install the “Android Auto App” on your Phone š Connect phone to PC
  47. None
  48. Testing Android Auto š adb forward tcp:5277 tcp:5277 š cd

    <sdk>/extras/google/auto š ./desktop-head-unit
  49. None
  50. Android Auto Audio Apps MediaBrowserService API UI Guidelines

  51. Extend MediaBrowserSerivce public class MyMusicService extends MediaBrowserService {

  52. Add your Service to Manifest <service android:name=".MyMusicService" android:exported="true"> <intent-filter> <action

    android:name="android.media.browse.MediaBrowserService" /> </intent-filter> </service>
  53. Register a session for Playback @Override public void onCreate() {

    super.onCreate(); mSession = new MediaSession(this, "MyMusicService"); setSessionToken(mSession.getSessionToken()); mSession.setCallback(new MediaSessionCallback()); mSession.setFlags(MediaSession.FLAG_HANDLES_MEDIA_BUTTONS | MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS); }
  54. More Actions in Action Cards

  55. Shallow Navigation Do this

  56. Deep Navigation Don’t do this

  57. Queue Screen Large clickable sections

  58. Android Auto Messaging Apps MessagingService API UI Guidelines

  59. Create Receivers and Service public class MessageReadReceiver extends BroadcastReceiver {

    … } public class MessageReplyReceiver extends BroadcastReceiver { … } public class MyMessagingService extends Service { … }
  60. Register them <service android:name=".MyMessagingService"></service> <receiver android:name=".MessageReadReceiver"> <intent-filter> <action android:name="com.codingblocks.exampleandroidauto.ACTION_MESSAGE_READ" />

    </intent-filter> </receiver> <receiver android:name=".MessageReplyReceiver"> <intent-filter> <action android:name="com.codingblocks.exampleandroidauto.ACTION_MESSAGE_REPLY" /> </intent-filter> </receiver>
  61. When message arrives @Override public void onReceive(Context context, Intent intent)

    { if (MyMessagingService.READ_ACTION.equals(intent.getAction())) { int conversationId = intent.getIntExtra(MyMessagingService.CONVERSATION_ID, -1); if (conversationId != -1) { Log.d(TAG, "Conversation " + conversationId + " was read"); NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context); notificationManager.cancel(conversationId); } } }
  62. When user replies @Override public void onReceive(Context context, Intent intent)

    { if (MyMessagingService.REPLY_ACTION.equals(intent.getAction())) { int conversationId = intent.getIntExtra(MyMessagingService.CONVERSATION_ID, -1); CharSequence reply = getMessageText(intent); Log.d(TAG, "Got reply (" + reply + ") for ConversationId " + conversationId); } }
  63. Get the user’s reply text from voice private CharSequence getMessageText(Intent

    intent) { Bundle remoteInput = RemoteInput.getResultsFromIntent(intent); if (remoteInput != null) { return remoteInput.getCharSequence(MyMessagingService.EXTRA_VOICE_REP LY); } return null; }
  64. Create handler in Service class IncomingHandler extends Handler { @Override

    public void handleMessage(Message msg) { sendNotification(1, "This is a sample message", "John Doe", System.currentTimeMillis()); } }
  65. Start read receiver from Service // A pending Intent for

    reads PendingIntent readPendingIntent = PendingIntent.getBroadcast(getApplicationContext(), conversationId, createIntent(conversationId, READ_ACTION), PendingIntent.FLAG_UPDATE_CURRENT);
  66. Start reply receiver from Service // Building a Pending Intent

    for the reply action to trigger PendingIntent replyIntent = PendingIntent.getBroadcast(getApplicationContext(), conversationId, createIntent(conversationId, REPLY_ACTION), PendingIntent.FLAG_UPDATE_CURRENT);
  67. Create notifications on the home screen NotificationCompat.Builder builder = new

    NotificationCompat.Builder(getApplicationContext()) //.setSmallIcon(R.drawable.notification_icon) //.setLargeIcon(personBitmap) .setContentText(message) .setWhen(timestamp) .setContentTitle(participant) .setContentIntent(readPendingIntent) .extend(new CarExtender() .setUnreadConversation(unreadConvBuilder.build())); mNotificationManager.notify(conversationId, builder.build());
  68. What happens when you get a message ?

  69. What happens when you get a message ?

  70. Day and Night Coloring Modes Because you can’t use it

    if you can’t see it
  71. Day and Night Coloring Modes Because it’s a car dashboard,

    not a headlight inside the car
  72. Day Mode

  73. Night Mode

  74. Some words of advice That you all will chose to

    ignore
  75. Eyes > Google Maps

  76. Driving > Replying

  77. Your phone renders an external display

  78. Read More Android Auto resources from Google http://andriod.com/auto https://developer.android.com /training/auto

    https://github.com/googlesam ples/android-MessagingService https://github.com/googlesam ples/android- MediaBrowserService
  79. Thank You ! dev@championswimmer.in twitter.com/championswimmer github.com/championswimmer