17. Notification Channels
CharSequence name = getString(R.string.noti_channel_group_default);
NotificationChannelGroup group =
new NotificationChannelGroup(DEFAULT_CHANNELS_GROUP_ID, name);
mNotificationManager.createNotificationChannelGroup(group);
18. Notification Channels
CharSequence name = getString(R.string.noti_channel_group_default);
NotificationChannelGroup group =
new NotificationChannelGroup(DEFAULT_CHANNELS_GROUP_ID, name);
mNotificationManager.createNotificationChannelGroup(group);
NotificationChannel channel = new NotificationChannel(
PRIMARY_CHANNEL,
getString(R.string.noti_channel_default),
NotificationManager.IMPORTANCE_DEFAULT);
channel.setGroup(DEFAULT_CHANNELS_GROUP_ID);
mNotificationManager.createNotificationChannel(channel);
19. Title with black text on black is background is bug of Android O Preview 1
21. Notifications API Changes
• Channel is required for all Notifications
• Notification priority is no effect, use channel
priorities instead.
• NotificationListenerService now can understand in
new onNotificationRemoved() method, that
notification was dismissed by a user or remove by
an app
22. Notification.Builder API Changes
• Notification.Builder(Context) is deprecated
Use Notification.Builder(Context, String) instead
• setTimeout()
Specify a duration after which a notification should be cancelled
• setColorized()
Set whether notification should be colorized. Color of notification
that was set by setColor() will be used as background color.
• chooseBadgeIcon()
Set type of icon to display as a badge for this notification
• setShortcutId()
Launcher can hide the shortcut, that notification duplicate. Ignored
be Launchers that don’t support badging or shortcuts.
26. Background Service Limitations
• Not applying for foreground apps
• Not applying for bounded Services
• System places background app on a temporary
whitelist for several minutes
• Handling high-priority FCM message
• Receiving broadcast such as SMS message
• Executing a PendingIntent from a notification
• Applying only for apps that target Android O
27. Foreground App
• Has a visible Activity (started or paused)
• Has foreground Service
• Another foreground app is connected to the app
Bind to one of its services or use one of its Content Providers
30. Broadcast Limitations
• Apps can no longer register Broadcast Receivers for
implicit broadcasts in manifest
• Explicit broadcasts not affected
• Registration for any broadcast using
Context.registerReceiver() at runtime not affected
• Limitation apply only to apps that target Android O
• A number of implicit broadcast are currently
exempted from this limitations
31. Some of exempted implicit
broadcasts
• ACTION_LOCALE_CHANGED
• ACTION_HEADSET_PLUG
• ACTION_CONNECTION_STATE_CHANGED
For BluetoothHeadset
• ACTION_NEW_OUTGOING_CALL
• ACTION_PACKAGE_FULLY_REMOVED
• ACTION_DEVICE_STORAGE_LOW
List of exempted actions can be changed before final release
33. JobScheduler
• Network conditions
• Charging state
• Idle state
• Time of execution
• Period
• Deadline
• Latency
• Can be persisted across device reboots
• Can be triggered based on Content provider changes
• Work with Doze & App Standby restrictions
34. Background Execution Limits
• System release all wakelocks when the app enters the
cached state (not active components)
• App in background receive location update only a few
times each hour
* Maybe changed in next Developer Previews
• The Service.startForeground() no longer works. Use
NotificationManager.startServiceInForeground() instead.
Affected to apps that target Android O
• The Context.startService() now throws an
IllegalStateExceptions if an app tries to use that method
where the Service will be restricted
41. New launcher icons rules
• Both layers must be sized at 108 × 108 dp
• The inner 72 × 72 dp of the icon appears within the
masked viewport
• Outer 36 dp on each sides reserved for visual
effectes
44. Autosizing TextView
• Granularity
Choose the best text size based on available space in range on
minimum & maximum sizes & a dimension that specifies the size
of step
• Preset Sizes
Choose the best text size from predefined sizes
50. Pinning Shortcuts requirements
• Default launcher must support pinning shortcuts
• When you attempt to pin a shortcut onto launcher,
the user receives a confirmation dialog asking their
permission to pin the shortcut
• ShortcutInfo requires short label & intent (or target
Activity)
• You can also pin App Widgets onto the launcher
52. Java 8 Date & Time
• Separated Date & Times classes
• Duration & Period classes
• Immutable
• Thread-safe
*You can user backport of Java 8 Date & Time - ThreeTen
53. Java 7/8 NIO API
• Path
• Stream API for files
• Work with file system info
• WatchService
54. Other Java API updates
• java.lang.invoke
Dynamic language support provided directly be the Java core class
libraries & VM
• java.util.Collections
• Collections.sort() is implemented on top of List.sort()
• Added checked, empty, synchronised & unmodifiable
wrapper method for NavigableMap & NavigableSet
56. Fragments
• Postpone Fragment enter transition
FragmentTransaction.postOnCommit(Runnable)
• Fragment lifecycle callback
• Primary Fragment
• Optimizations for FragmentTransactions
57. Permissions
• The app targeting Android O granted permissions it
has explicitly requested.
Once the user grants a permission to the app, all request for
permissions in that permission group are automatically granted
• Added android.permission.ANSWER_PHONE_CALLS
Allows apps to answer incoming phone calls
This is dangerous permission
Part of PHONE permission group
58. Cached data
• StorageManager.getCacheQuotaBytes()
Get disk space quota for cached data for the app
• New per-directory control how the system frees up cached data
• StorageManager.setCacheBehaviorAtomic()
All file in directory must be removed together
• StorageManager.setCacheBehaviorTombstone()
Do not delete files. Instead they should be truncated to be 0 bytes in length,
leaving the empty file intact
• Allocate disk space for files using StorageManager.allocateBytes()
It will automatically trigger clear cached files of the app & other apps (as needed) to
meet you request
• Use StorageManager.getAllocatableBytes() instead of using
File.getUsableSpace() for check is the device has enough disk
space to hold new data
It will consider any cached data the system is willing to clear on your behalf
59. Content Provider
• New query method with selection & sort params in
queryArgs Bundle
• Explicit refresh of content identified by URI
Use refresh(Uri, Bundle, CancelationSignal)
• Query pagination
• Content Provider usage stats change for all apps
Query for usage data of Contact provider now return approximations
rather then exact values for TIMES_CONTACTED, TIMES_USED,
LAST_TIME_CONTACTED, LAST_TIME_USED
• Behavior changes of ContentResolver.notifyChange() &
ContentResolver.registerContentObserver()
Require a valid ContentProvider for the authority in all URIs
61. Multi-display support
• Enhanced support for multiple displays
• User can move the Activity from one display to
another
If an activity supports multi-window mode.
• System resizes the Activity and issues runtime
changes as necessary, when an Activity is moved
between displays
• ActivityOptions contains new methods for control
display the Activity launch
62. WebView APIs
• Multiprocess WebView
Web content is handled in a separate, isolated process from the
containing app’s process
• Version API
Fetching information of app displaying web content in you app
• Google SafeBrowsing API
Verify URLs. using Google Safe Browsing
• Termination Handle API
Handling situations when system kills renderer process of WebView
• Renderer Importance API
Set a priority policy for the renderer assigned to a particular
WebView
63. Strict mode
• detectUnbufferedIo()
Detect when app access to data without buffering
• detectContentUriWithoutPermission()
Detect when app accidentally forgets to grant permissions to
another app when starting an Activity outside your app
• detectUntaggedSockets()
Detect when your app performs network traffics without using set
TrafficStats.setThreadStateTag() to tag your traffic for debugging
purposes
64. App categories
• Use to cluster together apps of similar purpose
when presenting them to users, such as in Data
Usage or Battery Usage
• Set android:appCategory attribute in your
<application> manifest tag
• Categories: audio, game, image, maps, news,
productivity, social, video
65. AccountManager API
• Control of visibility of accounts for other applications
• Now you can listen accounts updates only for
specified account types
• Apps can no longer get access to user accounts
unless the authenticator owns the accounts or the
user grants that access.
The GET_ACCOUNTS permission is no longer sufficient. Use
AccountManager.newChooseAccountIntent() to grant access.
• LOGIN_ACCOUNTS_CHANGED_ACTIONS is deprecated
Use AccountManager.addOnAccountsUpdatedListener() during
runtime
66. Smart sharing
Intent intent = new Intent(Intent.ACTION_CHOOSER);
ArrayList<String> annotations = new ArrayList<>(3);
annotations.add("person");
annotations.add("selfie");
annotations.add("child");
intent.putStringArrayListExtra(
Intent.EXTRA_CONTENT_ANNOTATIONS, annotations);
67. Alert windows changes
App that uses the SYSTEM_ALERT_WINDOW
permission & use one of the following window types
to display alert windows:
• TYPE_PHONE
• TYPE_PRIORITY_PHONE
• TYPE_SYSTEM_ALERT
• TYPE_SYSTEM_OVERLAY
• TYPE_SYSTEM_ERROR
68. Alert windows changes
• For apps that not target Android O, it will be
displayed beneath the windows, that use the
TYPE_APPLICATION_OVERLAY window type.
• Apps that target Android O can no longer use that
window types to display alert windows above other
apps & system windows. Instead, use new window
type called TYPE_APPLICATION_OVERLAY
69. Other updates
• View.findViewById() & View.findViewByTag() now
return generic type
No need cast anymore. Activity.findViewById() not changed
• View Tooltip
71. Other updates
• View.findViewById() & View.findViewByTag() now
return generic type
No need cast anymore. Activity.findViewById() not changed
• View Tooltip
• JobInfo transient extras
• AnimatorSet seeking & reverse playing
• Update Android ICU to version 58
• Settings.Secure.ANDROID_ID is unique for each app
& user
• SSLv3 no longer supported
72. Other updates
• Build.SERIAL is deprecated. Use Build.getSerial()
instead.
Build.getSerial() requires READ_PHONE_STATE permission
• android.app.ProgressDialog is deprecated
• Color mode in Configuration
73. Other Features
• Autofill Framework
• Picture-in-Picture for all
• Color management
• Wi-Fi Aware
• Companion device pairing
• Accessibility updates
• Media enhancements
74. Program overview
DP1 - alpha
DP2 - beta (Google I/O 2017?)
DP3 - Final APIs & SDK, Play publishing
DP4 - pre-final images
75. Try Android O Developer Preview
1. Install Android Studio 2.4
Use different Android SDK with stable Android 2.3
2. Download:
1. SDK & tools
2. Emulator image
3. Support libraries
3. Run emulator
Emulator only work if you ANDROID_SDK & ANDROID_SDK_ROOT
environment for Android SDK from Android Studio 2.4
Use emulator tools from canary Android SDK for work with
emulator