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.
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
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
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. 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. Sample Source code Link
https://github.com/googlecodelabs/getting-ready-for-android-n
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. 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. 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. 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.
21.
22. 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
23. 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
24.
25. 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.
29. 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.