getting your app ready for android n
TRANSCRIPT
ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
if (connMgr.isActiveNetworkMetered()) {
switch (connMgr.getRestrictBackgroundStatus) { case RESTRICT_BACKGROUND_STATUS_ENABLED:
// bg data blocked, use less data in fg too break; case RESTRICT_BACKGROUND_STATUS_WHITELISTED: // App should limit usage in fg and bg break; case RESTRICT_BACKGROUND_STATUS_DISABLED: // data saver disabled, but still on metered network break; }
•Direct Boot
•Number Blocking
•Call Screening
• Project Svelte: Background Optimizations
•OpenGL™ ES 3.2 API
Multi-Window : Split Screen
android:resizeableActivity=["true" | "false"]
<activity android:name=".MyActivity"> <layout android:defaultHeight="500dp" android:defaultWidth="600dp" android:gravity="top|end" android:minHeight="450dp" android:minWidth="300dp" /> </activity>
Multi-Window : Split Screen
android:resizeableActivity=["true" | "false"]
<activity android:name=".MyActivity"> <layout android:defaultHeight="500dp" android:defaultWidth="600dp" android:gravity="top|end" android:minHeight="450dp" android:minWidth="300dp" /> </activity>
Activity.isInMultiWindowMode()
Activity.onMultiWindowModeChanged()
Multi-Window : Split Screen
android:resizeableActivity=["true" | "false"]
<activity android:name=".MyActivity"> <layout android:defaultHeight="500dp" android:defaultWidth="600dp" android:gravity="top|end" android:minHeight="450dp" android:minWidth="300dp" /> </activity>
Activity.isInMultiWindowMode()
Activity.onMultiWindowModeChanged()
Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT
Multi-Window : Split Screen Intent intent = new Intent(Intent.ACTION_VIEW);intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT);
Drag And Dropandroid.view.DragAndDropPermissions Token object responsible for specifying the permissions granted to the app that receives a drop.
Drag And Dropandroid.view.DragAndDropPermissions Token object responsible for specifying the permissions granted to the app that receives a drop.
View.startDragAndDrop()
View.DRAG_FLAG_GLOBAL View.DRAG_FLAG_GLOBAL_URI_READ View.DRAG_FLAG_GLOBAL_URI_WRITE
Drag And Dropandroid.view.DragAndDropPermissions Token object responsible for specifying the permissions granted to the app that receives a drop.
View.startDragAndDrop()
View.DRAG_FLAG_GLOBAL View.DRAG_FLAG_GLOBAL_URI_READ View.DRAG_FLAG_GLOBAL_URI_WRITE
View.cancelDragAndDrop()
View.updateDragShadow()
Drag And Dropandroid.view.DragAndDropPermissions Token object responsible for specifying the permissions granted to the app that receives a drop.
View.startDragAndDrop()
View.DRAG_FLAG_GLOBAL View.DRAG_FLAG_GLOBAL_URI_READ View.DRAG_FLAG_GLOBAL_URI_WRITE
View.cancelDragAndDrop()
View.updateDragShadow()
Activity.requestDragAndDropPermissions() Requests the permissions for the content URIs passed with the ClipData contained in a DragEvent.
Creating a NotificationNotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.notification_icon) .setContentTitle("My notification") .setContentText("Hello World!");
Intent resultIntent = new Intent(this, ResultActivity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
stackBuilder.addParentStack(ResultActivity.class); stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.notify(mId, mBuilder.build());
Required notification contents
A Notification object must contain the following: • A small icon, set by setSmallIcon() • A title, set by setContentTitle() • Detail text, set by setContentText()
Notification.DecoratedCustomViewStyle()
Notification.DecoratedMediaCustomViewStyle()
Builder.setCustomContentView()
Notification priority
NotificationCompat.Builder.setPriority()
PRIORITY_MIN (-2) PRIORITY_MAX (2) PRIORITY_DEFAULT (0)
Removing Notification
• The user dismisses the notification either individually or by using "Clear All" (if the notification can be cleared).
• The user clicks the notification, and you called setAutoCancel() when you created the notification.
• You call cancel() for a specific notification ID. This method also deletes ongoing notifications.
• You call cancelAll(), which removes all of the notifications you previously issued.
Setting Visibility
You call setVisibility() and specify one of the following values:
• VISIBILITY_PUBLIC shows the notification's full content.
• VISIBILITY_SECRET doesn't show any part of this notification on the lock screen.
• VISIBILITY_PRIVATE shows basic information, such as the notification's icon and the content title, but hides the notification's full content.
Quick Settings Tile•Tile
holds the state of a tile that will be displayed in Quick Settings
•TileServiceprovides the user a tile that can be added to Quick Settings
TileSTATE_ACTIVE
STATE_INACTIVE
STATE_UNAVAILABLE
describeContents()
getContentDescription()
getIcon()
getLabel()
getState()setContentDescription (CharSequence contentDescription)
setLabel(CharSequence label)
setIcon(Icon icon)
setState(int state)
updateTile()writeToParcel(Parcel dest, int flags)
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.myapplication"> <application ... > <activity android:name="Main"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <meta-data android:name="android.app.shortcuts" android:resource="@xml/shortcuts" /> </activity> </application> </manifest>
Using Dynamic Shortcuts
Dynamic shortcuts should provide links to specific, context-sensitive actions within your app. These actions can change between uses of your app, and they can change even while your app is running. Good candidates for dynamic shortcuts include calling a specific person, navigating to a specific location, and viewing the current score for a specific game.
The ShortcutManager API allows you to complete the following operations on dynamic shortcuts:
• Publish: Use setDynamicShortcuts(List) to redefine the entire list of dynamic shortcuts, or use addDynamicShortcuts(List) to augment an existing list of dynamic shortcuts.
• Update: Use the updateShortcuts(List) method.
• Remove: Remove a set of dynamic shortcuts using removeDynamicShortcuts(List), or remove all dynamic shortcuts using removeAllDynamicShortcuts().
• Enhanced Live Wallpaper Metadata
• Round Icon Resources
When a launcher requests an app icon, the framework returns either android:icon or android:roundIcon, depending on the device build configuration.
• Storage Manager Intent
• Improved VR Thread Scheduling
• Demo User HintApps can now check to see if the device is running as the demo user.
• APIs for Carriers and Calling Apps
• New Screen Densities for Wear Devices
• DENSITY_260
• DENSITY_300
• DENSITY_340