Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Google I/O 2016 replay - Android N Development

275 views

Published on

This is the slide I used in the Google I/O Replay 2016 event (which was held on 4th June, 2016 at GPHouse, Bangladesh)

Published in: Software
  • Be the first to comment

  • Be the first to like this

Google I/O 2016 replay - Android N Development

  1. 1. Android N Getting your app ready & Quick Settings Implementation
  2. 2. Getting your app ready for Android N  Supporting multi-window layouts  Optimizing for battery efficiency  Support enhanced notifications
  3. 3. Supporting multi-window layouts  Decide what Activities are resizable
  4. 4. Supporting multi-window layouts
  5. 5. Supporting multi-window layouts  Create a new refs.xml file in a new resource directory called values-sw220dp. This qualifier will kick in if the smallest dimension is between 220dp and the next qualifier dimension, which is 400dp.
  6. 6. Supporting multi-window layouts
  7. 7. Supporting multi-window layouts Design for condensed sizes  To simplify adapting your app for the various sizes of split-screen mode, it is recommended to design for the smallest size first.  Create a layout that works at 220dp wide or tall by condensing elements or removing non-essential ones. The layout may be scaled upward from there.  If you are using similar layouts for phones and tablets, resizing should switch between them. If you are using very different layouts, avoid the phone UI layout and adapt the tablet layout instead.  Add a window background
  8. 8. Supporting multi-window layouts
  9. 9. Supporting multi-window layouts  Sometimes it makes sense to open a new activity in an adjacent window, when the user is in split-window mode. This is hinted to the system by adding the FLAG_ACTIVITY_LAUNCH_ADJACENT flag to the Intent
  10. 10. Optimizing for battery efficiency
  11. 11. Optimizing for battery efficiency
  12. 12. Optimizing for battery efficiency  For background work that isn't time critical (like checking email, or backing up photos), migrate to the JobScheduler or GcmNetworkManager APIs. These APIs provide greater flexibility for scheduling jobs, and ensure your background work is handled during a maintenance window.  For real-time notifications (like receiving an instant message), use high- priority GCM notifications. These have the ability to immediately wake up an app that's in a low-power state.  For applications which can't use either of these options, whitelisting may be an option as a last resort.
  13. 13. Support enhanced notifications  Android N enhances system notifications in a few ways:  Notification grouping is available on Phones and Tablets (not just Android Wear).  Notifications now support text input responses directly from the notification.  Notification templates have been visually and operationally refreshed.
  14. 14. Sample Source code Link  https://github.com/googlecodelabs/getting-ready-for-android-n
  15. 15. Android N: Quick Settings
  16. 16. Run the sample app  You can download the sample code from GitHub https://github.com/googlecodelabs/android-n-quick-settings/archive/master.zip  Run and you should see the Quick Settings Demo home screen appear after a few seconds.  Swipe down from the top of the device screen to open the notification shade.  Expand the shade and click Edit at the bottom right-hand corner.  From the bottom of the Edit shade, drag the Quick Settings Sample tile to the top part of the shade.
  17. 17. Update the Tile UI  To register a Quick Settings tile and corresponding service with the Android system, your manifest must include the service with a reference to the class that handles the tile. It must also include the android.permission.BIND_QUICK_SETTINGS_TILE permission and the android.service.quicksettings.action.QS_TILE intent filter. AndroidManifest.xml
  18. 18. Update the Tile UI  Now we will interact with the tile from the TileService at runtime  In the app/src/start/java/com.google.android_quick_settings/ directory, open QuickSettingsService.java and replace the override for the onClick method with the following code. QuickSettingsService.java
  19. 19. Update the Tile UI  Next, we'll add some code that updates the appearance of the tile. It gets a reference to the tile at runtime, changes the icon and the label, and the state of the tile based upon persisted data. QuickSettingsService.java
  20. 20. Update the Tile UI  Now we need to access and change the persisted data for the tile service. In the following code snippet, the app gets data from SharedPreferences, updates the setting, and then writes the updated setting back to SharedPreferences. QuickSettingsService.java
  21. 21. Update the Tile UI  Run and you should see the Quick Settings Demo home screen appear after a few seconds.  Swipe down from the top of the device screen to open the notification shade.  Tap the Quick Settings Demo tile repeatedly. You should see the tile icon, state, and label change as you tap
  22. 22. Launch a dialog from a tile  Create your own Quick Settings service that launches a dialog in response to a tile being tapped. The setting in the Android manifest file has already been added for you in the sample app.
  23. 23. QuickSettingsService.java
  24. 24. Launch an activity from a tile  In this final section, you'll create another Quick Settings TileService. This TileService class launches an activity in response to the user tapping the tile. You might use a pattern like this when you need to take the user directly to your app from the Quick Settings tile.
  25. 25. QSIntentService.java
  26. 26. THANKS… ?
  27. 27. Feel free to Contact ! I am Towhidul Haque Roni Blog: http://towhidulhaque.blogspot.com/ http://www.somewhereinblog.net/blog/throni/ Facebook: https://www.facebook.com/throni Twitter: https://twitter.com/throni87 LinkedIn: http://www.linkedin.com/pub/towhid ul-haque- roni/8/a2a/8b8 E-mail: throni@gmail.com

×