Android Wear Presentation

  • View
    681

  • Download
    1

Embed Size (px)

DESCRIPTION

Android Wear Talk at GDG Singapore

Text of Android Wear Presentation

  • 1. Introduction toAndroid WearTalk by Chua Zi Yonghttps://plus.google.com/+ZiYongChua

2. Learn more at www.gdg-sg.org/member Keep up to date with Google products and technologies Make new friends that are also passionate about technology Interact with Googlers Access to selected exclusive Google events Find jobs and developers related to Google products Contribute to developer community 3. Learn more at www.gdg-sg.org/memberBecause pictures speak a thousand words 4. Learn more at www.gdg-sg.org/memberFor more membership details,Visit http://bit.ly/gdg-sg-membersGet started today with just your email. 5. What is Android Wear?Introduction to Android Wear by Chua Zi Yong -https://plus.google.com/+ZiYongChua 6. What is Android Wear?Introduction to Android Wear by Chua Zi Yong -https://plus.google.com/+ZiYongChuaNotificationsApps on WearAndroid Fit 7. What is Android Wear?Introduction to Android Wear by Chua Zi Yong -https://plus.google.com/+ZiYongChua 8. What is Android Wear?Requires Android 4.3 and above AndroiddeviceLatest Google Play Services and Android Wearapp from Google Play installedInternet and connectivity over bluetooth frompaired deviceLimited function when connection is lostIntroduction to Android Wear by Chua Zi Yong -https://plus.google.com/+ZiYongChua 9. Getting Started InstallSDKInstall the Android Wear SDK Tools from ADT Android ADT Revision v22.6 and above Android Wear ARM EABI v7a system image Update Android Support LibraryIntroduction to Android Wear by Chua Zi Yong -https://plus.google.com/+ZiYongChua 10. Getting Started InstallemulatorTo install and test Android Wear emulator, youneed to (visit http://javapapers.com/android/android-wear-getting-started-tutorial/Introduction to Android Wear by Chua Zi Yong -https://plus.google.com/+ZiYongChuafor full details)1) Sign up for developer previewhttp://developer.android.com/wear/preview/signup.html2) Create AVD3) Connect Android device over adb (adb -d forward tcp:5601tcp:5601)4) Install Android Wear Preview from Google Play 11. Design for WearIntroduction to Android Wear by Chua Zi Yong -https://plus.google.com/+ZiYongChuaWear apps should be Launched automatically Glance-able Works like a personal butler Zero to low interactions 12. Design for WearTwo ways you can think of WearInteractions Extension of existing Android app notifications to workbetter on Android Wear (existing notifications on phonealready appears on Wear)Introduction to Android Wear by Chua Zi Yong -https://plus.google.com/+ZiYongChua Android Wear specific app 13. Notifications for WearExtending your existing notifications toWear You can add voice input/actions directly from Wear You can add additional content in pages By swiping left/right on the wearable You can stack multiple notificationsIntroduction to Android Wear by Chua Zi Yong -https://plus.google.com/+ZiYongChua 14. Notifications for WearAdding actions to Wear (It is verysimple) The same code before works the same on Wear (Includingnotification actions, big view) Use NotificationCompat.WearableExtender() for Wearable-onlyoptions (Appears only on Wear, not on phone) You can use addRemoteInput(remoteInput) to prompt userfor voice input P.S. Always use the NotificationManagerCompat instead ofNotificationManager (to support 4.1 and above features)Introduction to Android Wear by Chua Zi Yong -https://plus.google.com/+ZiYongChua 15. Notifications for WearAdding actions to Wear (Eliza samplecNootidficaetio)nCompat.Builder builder = new NotificationCompat.Builder(this) // All the usualstuffs.setContentTitle(getString(R.string.eliza)).setContentText(mLastResponse).setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.bg_eliza)).setSmallIcon(R.drawable.bg_eliza).setPriority(NotificationCompat.PRIORITY_MIN);Intent intent = new Intent(ACTION_RESPONSE); // Intent to do your stuffIntroduction to Android Wear by Chua Zi Yong -https://plus.google.com/+ZiYongChuaPendingIntent pendingIntent = PendingIntent.getService(this, 0, intent,PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_CANCEL_CURRENT);Notification notification = builder.extend(new NotificationCompat.WearableExtender() // New notificationextension for Wear.addAction(new NotificationCompat.Action.Builder(R.drawable.ic_full_reply, getString(R.string.reply), pendingIntent) //Get voice input.addRemoteInput(new RemoteInput.Builder(EXTRA_REPLY).setLabel(getString(R.string.reply)).build()).build())).build();NotificationManagerCompat.from(this).notify(0, notification); 16. Notifications for WearExtending your existing notifications toWear You can add voice input/actions directly from Wear You can add additional content in pages By swiping left/right on the wearable You can stack multiple notificationsIntroduction to Android Wear by Chua Zi Yong -https://plus.google.com/+ZiYongChua 17. Notifications for WearAdding additional content in pages(many at one time) For example, showing results of nearby search First, create an array list of notifications Next, generate a notification for each page you want todisplay, and add them to your array list Last, use .addPages(List)to parse in your arraylistIntroduction to Android Wear by Chua Zi Yong -https://plus.google.com/+ZiYongChua 18. Notifications for WearAdding additional content in pages (oneat a time) First, create the main (first) notification builder Next, create the new notification you want to insert Last, use .addPage(Notification) to add your notificationIntroduction to Android Wear by Chua Zi Yong -https://plus.google.com/+ZiYongChua 19. Notifications for WearAdding additional content in pagesNotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) //MainIntroduction to Android Wear by Chua Zi Yong -https://plus.google.com/+ZiYongChua.setSmallIcon(R.drawable.new_message).setContentTitle("Page 1").setContentText("Short message").setContentIntent(viewPendingIntent);Notification secondPageNotification = new NotificationCompat.Builder(this) // SecondNotification.build();Notification twoPageNotification = new WearableExtender().addPage(secondPageNotification) // Add second notification to main.extend(notificationBuilder).build();notificationManager = NotificationManagerCompat.from(this);notificationManager.notify(notificationId, twoPageNotification); 20. Notifications for WearExtending your existing notifications toWear You can add voice input/actions directly from Wear You can add additional content in pages By swiping left/right on the wearable You can stack multiple notificationsIntroduction to Android Wear by Chua Zi Yong -https://plus.google.com/+ZiYongChua 21. Notifications for WearStacking multiple notifications Use .setGroup(String key) to group your new notification toexisting group Use notify() to send the notification to WearIntroduction to Android Wear by Chua Zi Yong -https://plus.google.com/+ZiYongChua 22. Notifications for WearStacking multiple notificationsfinal static String GROUP_KEY_EMAILS = "group_key_emails"; // Key for groupIDNotification notif = new NotificationCompat.Builder(mContext)Introduction to Android Wear by Chua Zi Yong -https://plus.google.com/+ZiYongChua.setContentTitle("New mail from " + sender1).setContentText(subject1).setSmallIcon(R.drawable.new_mail);.setGroup(GROUP_KEY_EMAILS) // Set group ID into notification.build();NotificationManagerCompat notificationManager =NotificationManagerCompat.from(this);notificationManager.notify(notificationId1, notif); // Send out the notification 23. Design for WearTwo ways you can think of WearInteractions Extension of existing Android app notifications to work betteron Android Wear (existing notifications on phone alreadyappears on Wear)Introduction to Android Wear by Chua Zi Yong -https://plus.google.com/+ZiYongChua Android Wear specific app 24. Wear App API ArchitecturePhone APK Wear APKIntroduction to Android Wear by Chua Zi Yong -https://plus.google.com/+ZiYongChua 25. Wear App API ArchitectureNode API- Inform when Wear is connectedIntroduction to Android Wear by Chua Zi Yong -https://plus.google.com/+ZiYongChuaMessage API- Manage API callsbetween devicesData API- Centralized data storemanaged by GPSGPSMagic 26. Wear App API ArchitectureIntroduction to Android Wear by Chua Zi Yong -https://plus.google.com/+ZiYongChua 27. Wear App API ArchitectureIntroduction to Android Wear by Chua Zi Yong -https://plus.google.com/+ZiYongChua 28. Wear App API ArchitectureIntroduction to Android Wear by Chua Zi Yong -https://plus.google.com/+ZiYongChua 29. Wear App API ArchitectureTo start communicating with the Wearable, weneed to initialize the GoogleApiClient on thephone APKmGoogleApiClient = new GoogleApiClient.Builder(this)Introduction to Android Wear by Chua Zi Yong -https://plus.google.com/+ZiYongChua.addApi(Wearable.API).build();mGoogleApiClient.connect(); 30. Wear App API ArchitectureWearableListenerService will handle all thecallbacks from Google Play Services on wear// Insert the service into the manifest of the Weak.apk, in this case name it// AppListenerService (subclass of Abstract class WearableListenerService)Introduction to Android Wear by Chua Zi Yong -https://plus.google.com/+ZiYongChua 31. Wear App API ArchitectureIn AppListenerService.java, you can managethe callbacks from Node, Data and MessagelistenersIntroduction to Android Wear by Chua Zi Yong -https://plus.google.com/+ZiYongChua 32. Add Voice Action to WearYou can trigger your app through voice actionsIntroduction to Android Wear by Chua Zi Yong -https://plus.google.com/+ZiYongChua 33. Add Voice Action to WearJust add the intent filter to your WearActivitiyIntroduction to Android Wear by Chua Zi Yong -https://plus.google.com/+ZiYongChua 34. Add Voice Action to WearAvailable commands today (approval processsimilar to Google Glass)More details:https://developer.android.com/training/wearables/apps/voice.htmlIntroduction to Android Wear by Chua Zi Yong -https://plus.google