what's new in android
TRANSCRIPT
![Page 1: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/1.jpg)
![Page 2: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/2.jpg)
What's New in AndroidChet HaaseRomain GuyDan SandlerAndroid Framework Engineers
![Page 3: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/3.jpg)
What's New in AndroidChet HaaseRomain GuyDan SandlerAndroid Framework Engineers
4.1 Jelly Bean
![Page 4: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/4.jpg)
So What is New, Anyway?
• Performance• Framework features• Graphics and media• Google Play• SDK and tools• Notifications
2
![Page 5: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/5.jpg)
Now, with More Butter!
• VSync’d drawing and animations- New Choreographer and TimeAnimator classes
• Streaming input• Faster invalidation and drawing• Triple buffering as needed
3
“For Butter or Worse”: Thursday @ 2:45
![Page 6: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/6.jpg)
Widgets & Wallpapers
• Widgets in third party launchers- AppWidgetManager.ACTION_APPWIDGET_BIND
• Widgets can respond to size changes- AppWidgetProvider.onAppWidgetExtrasChanged()
• Landscape and portrait layouts for remote views• Memory limit for remote views
- Function of screen size• GridLayout and ViewStub remoteable• New intent for viewing app wallpapers
- ACTION_CHANGE_LIVE_WALLPAPER
4
![Page 7: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/7.jpg)
Animation Goodies
• ViewPropertyAnimator• LayoutTransition
5
![Page 8: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/8.jpg)
1: view.animate().alpha(0);2: 3: view.animate().translationX(500);4: 5: view.animate().alpha(0).translationX(500);
6
![Page 9: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/9.jpg)
view.animate().rotationY(180).withLayer();
7
![Page 10: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/10.jpg)
view.animate().rotationY(180).withLayer();
7
![Page 11: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/11.jpg)
8
view.animate().translationX(0).withStartAction(new Runnable() { public void run() { view.setTranslationX(-view.getWidth()); }});
view.animate().alpha(0).withEndAction(new Runnable() { public void run() { parent.removeView(view); }});
![Page 12: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/12.jpg)
8
view.animate().translationX(0).withStartAction(new Runnable() { public void run() { view.setTranslationX(-view.getWidth()); }});
view.animate().alpha(0).withEndAction(new Runnable() { public void run() { parent.removeView(view); }});
![Page 13: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/13.jpg)
9
LayoutTransition t = new LayoutTransition();
t.enableTransitionType(LayoutTransition.CHANGING);
container.setLayoutTransition(t);
![Page 14: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/14.jpg)
9
LayoutTransition t = new LayoutTransition();
t.enableTransitionType(LayoutTransition.CHANGING);
container.setLayoutTransition(t);
![Page 15: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/15.jpg)
Framework tidbits
• Improved TextView- Non-editable TextViews use less memory- Increased performance for long text
• Support for styled text in ClipData• Better system-wide memory management
- ActivityManager.getMyMemoryState()- ComponentCallbacks2.TRIM_*
• From Android 4.0 ICS in case you missed them- GridLayout- TextureView
• Database query cancellation- Cursors, ContentProviders and Loaders
10
![Page 16: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/16.jpg)
11
signal = new CancellationSignal();signal.setOnCancelListener(new OnCancelListener() { @Override public void onCancel() { // Cancelled contacts query }});
Cursor c = r.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null, signal);
signal.cancel();
![Page 17: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/17.jpg)
11
signal = new CancellationSignal();signal.setOnCancelListener(new OnCancelListener() { @Override public void onCancel() { // Cancelled contacts query }});
Cursor c = r.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null, signal);
signal.cancel();
![Page 18: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/18.jpg)
11
signal = new CancellationSignal();signal.setOnCancelListener(new OnCancelListener() { @Override public void onCancel() { // Cancelled contacts query }});
Cursor c = r.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null, signal);
signal.cancel();
![Page 19: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/19.jpg)
11
signal = new CancellationSignal();signal.setOnCancelListener(new OnCancelListener() { @Override public void onCancel() { // Cancelled contacts query }});
Cursor c = r.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null, signal);
signal.cancel();
![Page 20: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/20.jpg)
Activity animations
• More control over animations when starting activities- android.app.ActivityOptions- Enables new ‘zoom’ animations
12
![Page 21: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/21.jpg)
![Page 22: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/22.jpg)
Demo
![Page 23: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/23.jpg)
14
ActivityOptions opts;opts = ActivityOptions.makeScaleUpAnimation(view, 0, 0, view.getWidth(), view.getHeight());
startActivity(myIntent, opts.toBundle());
![Page 24: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/24.jpg)
14
ActivityOptions opts;opts = ActivityOptions.makeScaleUpAnimation(view, 0, 0, view.getWidth(), view.getHeight());
startActivity(myIntent, opts.toBundle());
![Page 25: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/25.jpg)
14
ActivityOptions opts;opts = ActivityOptions.makeScaleUpAnimation(view, 0, 0, view.getWidth(), view.getHeight());
startActivity(myIntent, opts.toBundle());
![Page 26: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/26.jpg)
Navigation
• New TaskStackBuilder- Helps you create synthetic task stacks
• Automatic ‘up’ navigation for activities• Available in the support library
15
![Page 27: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/27.jpg)
16
<activity android:name=".app.ContentActivity" android:label="Content" android:parentActivityName=".app.HomeActivity"> <!-- ... --> </activity>
![Page 28: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/28.jpg)
16
<activity android:name=".app.ContentActivity" android:label="Content" android:parentActivityName=".app.HomeActivity"> <!-- ... --> </activity>
![Page 29: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/29.jpg)
17
TaskStackBuilder.create(this) .addParentStack(ContentActivity.class) .addNextIntent(new Intent(this, ContentActivity.class) .putExtra(ContentActivity.EXTRA_TEXT, "From Notification") .startActivities();
![Page 30: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/30.jpg)
17
TaskStackBuilder.create(this) .addParentStack(ContentActivity.class) .addNextIntent(new Intent(this, ContentActivity.class) .putExtra(ContentActivity.EXTRA_TEXT, "From Notification") .startActivities();
![Page 31: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/31.jpg)
Aligning XML Attributes and Java properties
• More consistent and toolable APIs
• For example:
18
scrollbarSize public void setScrollbarSize(int);public int getScrollbarSize();
Before Added
View
ImageViewmaxWidthpublic void setMaxWidth(); public int getMaxWidth();
![Page 32: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/32.jpg)
Internationalization
19
![Page 33: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/33.jpg)
Internationalization
• New locales and fonts- Arabic- Hebrew
• Improved support for right-to-left text- TextView- EditText- StaticLayout, etc.- Canvas
• Performance improvements with RTL text
19
![Page 34: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/34.jpg)
20
![Page 35: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/35.jpg)
Accessibility
• Gesture-based traversal of all onscreen elements- AccessibilityService.GESTURE_SWIPE_UP, GESTURE_SWIPE_DOWN, ...- Including navigation buttons
• AccessibilityService.GLOBAL_ACTION_HOME, BACK, RECENTS, NOTIFICATIONS
• Double-tap activates current element• Text reading by word, line, or paragraph• Just works for standard views
- View.setImportantForAccessibility() for special cases• Custom views with semantic structure
- Override View.getAccessibilityNodeProvider()• Support library
21
“Making Android Apps Accessible”: Wednesday @ 5:15
![Page 36: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/36.jpg)
External Storage Access
22
android.permission.READ_EXTERNAL_STORAGE
![Page 37: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/37.jpg)
Limiting Costly Downloads
23
ConnectivityManager.isActiveNetworkMetered()
![Page 38: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/38.jpg)
Renderscript Compute
• Support for NEON instructions- Use new #pragma rs_fp_relaxed
• Texture sampling, like you would do from a fragment shader on a GPU- rsSample()
• Debugging on x86 emulator and x86 devices!• Multiple root()-style kernels in a single file
24
“Doing More with Less”: Thursday @ 4
![Page 39: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/39.jpg)
Media
• API access to low-level codec data• See “Media Codec APIs in Android Jellybean”
25
“Media Codec APIs in Android Jelly Bean”: Today @ 4
![Page 40: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/40.jpg)
Audio Latency Improvements
• Latency improvements for- OpenSL- soundpool- tone generator
• Significant improvements in warm latency for some devices- Device-dependent
• More to come
26
![Page 41: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/41.jpg)
NFC
• Large payloads over Bluetooth- Move files with a tap
• Tap-to-pair for Bluetooth headsets and speakers
27
“Up Close and Personal: NFC and Android Beam”: Thursday @ 4
![Page 42: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/42.jpg)
Google Play
28
Respond to user comments
![Page 43: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/43.jpg)
Google Play
29
In-app subscriptions
![Page 44: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/44.jpg)
And more...
• New seller countries• Team access to the Android Developer Console• Sales reports• Android Expansion Files
- APK up to 50 MB- Expansions files up to 4 GB
• Optimized APK updates• Unlocked devices available on Play
30
“Android Apps in Google Play”: Today @ 1:30
![Page 45: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/45.jpg)
developer.android.com
31
![Page 46: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/46.jpg)
developer.android.com
31
DesignDevelop
Distribute
![Page 47: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/47.jpg)
Tools
• Emulator with x86 virtualization- Android 2.3- Android 4.0
• GPU support for the emulator- With Android 4.0.3+- Supports OpenGL ES 1.x and 2.x- Supports hardware accelerated applications
• Sensor and multitouch support through physical Android devices
32
![Page 48: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/48.jpg)
Tools
• New tool: lint• New tool: Tracer for OpenGL ES• New tool: Device Monitor• New tool: System Trace
33
![Page 49: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/49.jpg)
ADT
• Integration with new tools- lint, Tracer for OpenGL ES, etc.
• Application templates• Improved NDK support
- Build- Debug
• Improved layout editor- New property sheet
• Numerous UI and performance improvements
34
“What’s New in Android Developers’ Tools”: Thursday @ 11:45
![Page 50: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/50.jpg)
Notifications in 4.1
35
![Page 51: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/51.jpg)
Notifications in 4.1
35
![Page 52: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/52.jpg)
Android Notifications
36
audioStreamTypecontentIntentcontentViewdefaultsdeleteIntentflagsiconiconLevelledARGBledOffMSledOnMSnumber
soundtickerTextvibratewhenfullScreenIntent (9)largeIcon (11)tickerView (11)
API 1–15
![Page 53: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/53.jpg)
Android Notifications
36
audioStreamTypecontentIntentcontentViewdefaultsdeleteIntentflagsiconiconLevelledARGBledOffMSledOnMSnumber
soundtickerTextvibratewhenfullScreenIntent (9)largeIcon (11)tickerView (11)
API 1–15
icon
![Page 54: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/54.jpg)
Android Notifications
36
audioStreamTypecontentIntentcontentViewdefaultsdeleteIntentflagsiconiconLevelledARGBledOffMSledOnMSnumber
soundtickerTextvibratewhenfullScreenIntent (9)largeIcon (11)tickerView (11)
API 1–15
icon
contentView
![Page 55: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/55.jpg)
Android Notifications
37
audioStreamTypecontentIntentcontentViewdefaultsdeleteIntentflagsiconiconLevelledARGBledOffMSledOnMSnumber
soundtickerTextvibratewhenfullScreenIntentlargeIcontickerViewbigContentViewpriority
API 16: Jelly Bean
![Page 56: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/56.jpg)
Android Notifications
37
audioStreamTypecontentIntentcontentViewdefaultsdeleteIntentflagsiconiconLevelledARGBledOffMSledOnMSnumber
soundtickerTextvibratewhenfullScreenIntentlargeIcontickerViewbigContentViewprioritybigContentView
API 16: Jelly Bean
![Page 57: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/57.jpg)
Android Notifications
37
audioStreamTypecontentIntentcontentViewdefaultsdeleteIntentflagsiconiconLevelledARGBledOffMSledOnMSnumber
soundtickerTextvibratewhenfullScreenIntentlargeIcontickerViewbigContentViewprioritybigContentViewpriority
API 16: Jelly Bean
![Page 58: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/58.jpg)
NO NEW ICON GUIDELINES.
38
![Page 59: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/59.jpg)
NO NEW ICON GUIDELINES.
38
(WAIT FOR APPLAUSE)
![Page 60: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/60.jpg)
priority
39
![Page 61: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/61.jpg)
IMPORTANT!!1!
40
Notification.priority
Notification.Builder.setPriority(int)
PRIORITY_MAX = 2PRIORITY_HIGH = 1PRIORITY_DEFAULT = 0PRIORITY_LOW = –1PRIORITY_MIN = –2
![Page 62: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/62.jpg)
This field is a hint to the System UI
It helps the system manage the user’s attentionby exposing the intended urgency of your Notificationyour notification may change position or appearance depending on its priority
You can finally stop using FLAG_ONGOING to sort to the topUse higher priorities, SystemUI will do the rest
You can now create notifications that do not appear in the status barUse PRIORITY_MIN to tell System UI to hide your icon, but show you in the expanded panel
Use this for “opportunistic” notifications: attention not required
41
![Page 63: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/63.jpg)
Priority buckets
42
expired eventssuggestions
detailed statusapp promos
incoming callsturn-by-turn directions
emergency alerts
MAX HIGH – DEFAULT – LOW MIN
important emailsSMS/chat“widgets”
junk mailchatty apps
very urgent/active tasks
everything else(and all pre-JB notifications)
most notifications go here opportunistic
![Page 64: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/64.jpg)
When in doubt, PRIORITY_DEFAULT.
43
![Page 65: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/65.jpg)
bigContentView
44
![Page 66: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/66.jpg)
It’s kind of a big deal
45
![Page 67: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/67.jpg)
The first major new feature in Notifications since 1.0
46
![Page 68: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/68.jpg)
The first major new feature in Notifications since 1.0
46
contentView: still the same as before64dp tall (“1U”)created for you by Notification.Builderincludes your icon, contentTitle, contentText, when, number, …or, as always, roll your own RemoteViews
![Page 69: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/69.jpg)
The first major new feature in Notifications since 1.0
46
contentView: still the same as before64dp tall (“1U”)created for you by Notification.Builderincludes your icon, contentTitle, contentText, when, number, …or, as always, roll your own RemoteViews
bigContentView: like contentView, but…biggerup to 256dp tall (“4U”)a big canvas for text, photos, lists of messages, you name it
The platform is here to helpNew platform APIs to make great-looking big notificationsor, as always, roll your own RemoteViews
![Page 70: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/70.jpg)
Actions
47
![Page 71: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/71.jpg)
Actions
47
![Page 72: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/72.jpg)
ActionsAdd up to 3 buttonsCan be used with any notificationGet things done right there
Uses1. Visit a different activity than the click
handler (contentIntent)
2. Take some action in the background
ProtipTo show that an action has been taken, set the intent to null and re-notify()
48
new Notification.Builder(this) .setContentTitle("Missed call") .setContentText("Hiroshi Lockheimer") .setLargeIcon(bitmap) .setSmallIcon(R.drawable.missed_call) .setPriority( Notification.PRIORITY_HIGH) .setContentIntent(callLogIntent) .addAction(R.drawable.call, "Call Back", callMeMaybe) .addAction(R.drawable.text, "Message", sendSms) .build();
![Page 73: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/73.jpg)
BigTextStyle
49
![Page 74: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/74.jpg)
BigTextStyle
49
![Page 75: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/75.jpg)
BigTextStyle
A big multi-line TextViewLet your message run free*!Users may be able to get everything they need from the notification
Actions are a force multiplierTriage and act without visiting the app
ProtipsYou can use the same string for contentText and bigText (but probably not for the ticker)Styles and newlines are OK, but exercise taste
50
new Notification.Builder(this) .setSmallIcon(…) .setLargeIcon(…) .setContentTitle(senderName) .setTicker(tickerText) .addAction(…) .setContentText(msgText) .setStyle( new Notification.BigTextStyle() .bigText(msgText)) .build();* up to the 4U size limit of expandable notifications
![Page 76: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/76.jpg)
BigPictureStyle
51
![Page 77: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/77.jpg)
BigPictureStyle
51
![Page 78: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/78.jpg)
BigPictureStyle
Pretty sure this one is obviousGreat for showcasing visual contentSupply your own BitmapThe image will be centerCropped
ProtipsImages should be ≤ 450dp wide, ~2:1 aspectBitmaps outside these bounds will just be wasting RAM (and possibly exceeding Binder IPC limits)
52
new Notification.Builder(this) … .setStyle( new Notification.BigPictureStyle() .bigPicture(photoBits)) .build();
![Page 79: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/79.jpg)
InboxStyle
53
![Page 80: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/80.jpg)
InboxStyle
53
![Page 81: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/81.jpg)
InboxStyle
Great for any kind of listNew messagesHeadlinesAgendaBatched notifications
ProtipsUse styled text to emphasize content and add visual structureUse setSummaryText() to append info such as account name or “+ 5 more”
54
new Notification.Builder(this) .setContentTitle("3 new messages") .setContentText("You have mail!") .setSubText("[email protected]") .setNumber(3) .setSmallIcon(R.drawable.email)) .setStyle( new Notification.InboxStyle() .addLine(styledLine1) .addLine(styledLine2) .addLine(styledLine3)) .build();
![Page 82: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/82.jpg)
Magical incantations
55
![Page 83: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/83.jpg)
Magical incantations
55
Pulldown
![Page 84: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/84.jpg)
Magical incantations
55
Pulldown Spread
![Page 85: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/85.jpg)
Magical incantations
55
Pulldown Spread Stretch
![Page 86: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/86.jpg)
Magical incantations
55
Pulldown Spread Stretch The Screwdriver
![Page 87: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/87.jpg)
Magical incantations
55
Pulldown Spread Stretch The Screwdriver
![Page 88: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/88.jpg)
Spring-loaded
We expand the topmost notification by defaultIf it’s got a bigContentView
Users who don’t know about the gestures will still benefit from the feature
The system will sort notifications first by priority, then timeTherefore: more details about the most important stuff, automatically
Protip: swipe the top notification awayThe next one will pop up and automatically expand
56
![Page 89: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/89.jpg)
Accountability
Users can now long-press a notificationto discover which package posted itTakes you to the App Info activity in Settings
Users can then:uninstall the package, ordisable all notifications from that package
Protip: don’t annoy the user
57
![Page 90: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/90.jpg)
Examples
58
→
![Page 91: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/91.jpg)
Android & Google
59
…and more
![Page 92: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/92.jpg)
foursquare
60
![Page 93: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/93.jpg)
Spotify
61
TuneIn
![Page 94: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/94.jpg)
Pulse
62
![Page 95: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/95.jpg)
GigBeat
63
![Page 96: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/96.jpg)
Path
64
![Page 97: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/97.jpg)
Pocket Gems
65
![Page 98: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/98.jpg)
“The idea is to be as unobtrusive as possible, while still showing the user the information you want them to see.”
66
Notification API documentationSDK m3-rc20a, November 2007
2007
![Page 99: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/99.jpg)
This is still true.
67
![Page 100: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/100.jpg)
The user’s attention is precious
68
Notifications in Jelly Bean: new tools to manage attention
priorityshow the most urgent things first, not just the most recentbig notificationsgive the user more information, effortlessly, on demandactionslet the user get things done … and go back to what they were doing
![Page 101: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/101.jpg)
Other Jelly Bean-Related I/O Sessions
• Wednesday 4:00: Media Codecs in Android Jelly Bean • Wednesday 5:15: Android Fireside Chat• Wednesday 5:15: Making Android Apps Accessible• Thursday 11:45 What’s New in Android Developers’ Tools• Thursday 2:45: For Butter or Worse: Smoothing Out Performance in Android UIs• Thursday 4:00: Doing More with Less: Being a Good Android Citizen
69
![Page 102: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/102.jpg)
![Page 103: What's New in Android](https://reader031.vdocuments.mx/reader031/viewer/2022020207/5533bec64a7959614e8b4a02/html5/thumbnails/103.jpg)
Q&A+Chet Haase @chethaase+Romain Guy @romainguy+Daniel Sandler @dsandler