Diese Präsentation wurde erfolgreich gemeldet.
Die SlideShare-Präsentation wird heruntergeladen. ×

I/O Rewind 215: What's new in Android

Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Nächste SlideShare
Android N multi window
Android N multi window
Wird geladen in …3
×

Hier ansehen

1 von 78 Anzeige
Anzeige

Weitere Verwandte Inhalte

Diashows für Sie (20)

Ähnlich wie I/O Rewind 215: What's new in Android (20)

Anzeige

Weitere von Sittiphol Phanvilai (10)

Aktuellste (20)

Anzeige

I/O Rewind 215: What's new in Android

  1. 1. What’s new in Android M nuuneoi
  2. 2. Stands for ... mmmm
  3. 3. Stands for ... Preview
  4. 4. Building M Preview Apps Android M is now available on SDK Manager
  5. 5. Building M Preview Apps
  6. 6. Previewssssss
  7. 7. OK. Let’s start.
  8. 8. Apps Permission FASTER INSTALLS • SMOOTHER UPGRADES • MORE USER CONTROL
  9. 9. Install-time permissions
  10. 10. Runtime permissions in M
  11. 11. User controls in M
  12. 12. Everything you’ve ever asked for But now your app has to deal with it
  13. 13. Apps targeting M can: can ask for any permission at any time Legacy apps will: get all permissions at install time, as before Users can: deny any permissions upon request deny any permissions at any later time – even legacy apps Test!
  14. 14. Voice Interactions
  15. 15. Voice Interactions VoiceInteractor – confirm and prompt for response <activity android:name="org.example.MyVoiceActivity"> <intent-filter> <action android:name="org.example.MY_ACTION_INTENT" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.VOICE" /> </intent-filter> </activity>
  16. 16. Voice Interactions public class MyVoiceActivity extends AppCompatActivity { @Override protected void onResume() { super.onResume(); if (isVoiceInteraction()) { // do stuff } else { finish(); } }
  17. 17. Voice Interactions public class MyVoiceActivity extends AppCompatActivity { @Override protected void onResume() { super.onResume(); if (isVoiceInteraction()) { String prompt = "..."; getVoiceInteractor().submitRequest( new Confirm(prompt)); } else { finish(); } }
  18. 18. Voice Interactions public class Confirm extends VoiceInteractor.ConfirmationRequest { public Confirm(String prompt) { super(prompt, null); } @Override public void onConfirmationResult( boolean confirmed, Bundle result) { if (confirmed) { // do stuff } } } public class MyVoiceActivity extends AppCompatActivity { @Override protected void onResume() { super.onResume(); if (isVoiceInteraction()) { String prompt = "..."; getVoiceInteractor().submitRequest( new Confirm(prompt)); } else { finish(); } }
  19. 19. Fingerprint QUICK USER VERIFICATION
  20. 20. Two APIs for fingerprints FingerprintManager.authenticate() Verify that authorized user is present Your app controls all UI KeyguardManager.createConfirmDeviceCredentialIntent() Present lock screen to user startActivityForResult(), check for RESULT_OK Sample code github.com/googlesamples/android-FingerprintDialog github.com/googlesamples/android-ConfirmCredential
  21. 21. Android Backup RESTORATION SOFTWARE
  22. 22. Android Backup All data now backed up by default targetSdk M Optional scheme file in xml/ resource dir includes/excludes
  23. 23. Android Backup AndroidManifest.xml <application android:fullBackupContent="@xml/mybackupscheme"> ... </application> res/xml/mybackupscheme.xml <full-backup-content> <exclude domain="database" path="device_info.db"/> </full-backup-content> or <full-backup-content> <include domain="file" path="mydata/allthatmatters.txt"/> </full-backup-content>
  24. 24. Google Play Services 7.5 AND COUNTING
  25. 25. GCM Network Manager Like JobScheduler … but across releases OneOffTask PeriodicTask Limit network requests to wifi, or charging, or …
  26. 26. Also… Maps on Android Wear App Invites Cast Remote Display Smart Lock for Passwords …
  27. 27. Power EVEN BETTER BATTERY LIFE
  28. 28. Power improvements Better screen-off battery life Doze Untouched devices become “inactive” Wait longer to wake up for background tasks Resume normal operation when moved, used, or plugged in App standby Unused apps lose network access Resume when launched/used or when plugged in
  29. 29. Assistant Support CONTEXTUAL INFORMATION, WHEN THE USER NEEDS IT
  30. 30. Assistant Support New APIs to provide the assistant with relevant data See SDK docs: Activity.onProvideAssistData(Bundle) Application.OnProvideAssistDataListener
  31. 31. Data Binding BOUNDS AND DETERMINED
  32. 32. Data Binding Connecting data and UI elements Automates listener creation, message sending, setters, … Pre-processed at build time
  33. 33. Data Binding <layout> <data> <variable name="item" type="com.android.example.store.Item"/> </data> <FrameLayout ...> <ImageView ... android:src="@{item.image}" /> <TextView ... android:text="@{@string/price(item.dollars, item.cents)}" /> </FrameLayout> </layout>
  34. 34. UI Features ALL ABOUT YOU AND I
  35. 35. Android Design Support Library Snackbar
  36. 36. Android Design Support Library Snackbar FAB
  37. 37. Android Design Support Library Snackbar FAB CoordinatorLayout
  38. 38. Android Design Support Library Snackbar FAB CoordinatorLayout TabLayout
  39. 39. Android Design Support Library Snackbar FAB CoordinatorLayout TabLayout TextInputLayout
  40. 40. Android Design Support Library Snackbar FAB CoordinatorLayout TabLayout TextInputLayout NavigationView
  41. 41. Other UI Changes RecyclerView ItemTouchHelper Swipe-to-dismiss Drag & drop WebView PostMessage WebViewClient WebSettings.setOffscreenPreRaster()
  42. 42. Notifications HEY! YOU THERE! LOOK UP HERE!
  43. 43. android.graphics.drawable.Icon Holds either: a drawable resource id a Bitmap a byte[] holding a PNG or JPEG
  44. 44. Icons in Notifications Icon ic = Icon.createWithResource(context, R.drawable.ic_notification); Notification no = Notification.Builder(context) .setSmallIcon(ic) ... .build();
  45. 45. Icons in Notifications Icon ic = Icon.createWithBitmap(iconBitmap); Notification no = Notification.Builder(context) .setSmallIcon(ic) ... .build();
  46. 46. Text Stuffs TEXT IS ALL AROUND
  47. 47. Text Selection Easier Selection Floating palette with action items Default for TextView Other views set ActionMode.TYPE_FLOATING
  48. 48. Text Processing <intent-filter> <action android:name="android.intent.action.PROCESS_TEXT"/> </intent-filter>
  49. 49. Higher Quality Text Formatting TextView.setBreakStrategy(int); TextView.setHyphenationFrequency(int); TextView.setIndents(int[] left, int[] right);
  50. 50. App Links RELATIONSHIP BETWEEN APP AND WEB DOMAINS
  51. 51. App Links Understand the relationship between an app and web domains owned by the same developer d.android.com/preview/features/app-linking.html
  52. 52. [{ "relation": ["delegate_permission/common.handle_all_urls"], "target": { "namespace": "android_app", "package_name": “com.example.myapp", "sha256_cert_fingerprints": ["6C:EC:C5:0E:34:AE....EB:0C:9B"] } }] http://example.com/.well-known/statements.json https: for M final keytool -list -v -keystore release.keystore
  53. 53. Establishing app links At install time Package Manager fetches statements.json Matches hash to APK’s signing certificate These links will now launch your app On failure, a link is not created Usual intent chooser will be shown Users can review & modify app links Settings -> Apps -> (Your App) -> Open by default
  54. 54. <activity ...> <intent-filter android:autoVerify="true"> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="http" android:host=“example.com" /> <data android:scheme="http" android:host="www.example.com" /> </intent-filter> </activity> AndroidManifest.xml This is where we will look for /.well-known/statements.json
  55. 55. Establishing app links At install time Package Manager fetches statements.json Matches hash to APK’s signing certificate These links will now launch your app On failure, a link is not created Usual intent chooser will be shown Users can review & modify app links Settings -> Apps -> (Your App) -> Open by default
  56. 56. Direct Share SHARING IS EVEN MORE AWESOME
  57. 57. Direct Share <activity ...> <intent-filter> <action android:name="android.intent.action.SEND" /> </intent-filter> <meta-data android:name="android.service.chooser.chooser_target_service" android:value=".MyChooserTargetService" /> </activity> <service android:name=".MyChooserTargetService" android:permission="android.permission.BIND_CHOOSER_TARGET_SERVICE"> <intent-filter> <action android:name="android.service.chooser.ChooserTargetService" /> </intent-filter> </service> public class MyChooserTargetService extends ChooserTargetService { @Override public List<ChooserTarget> onGetChooserTargets(ComponentName targetActivityName, IntentFilter matchedFilter) { // do stuff } }
  58. 58. Stylus support NOW THE PRESSURE IS REALLY ON
  59. 59. Styluses: supported since ICE_CREAM_SANDWICH MotionEvent APIs: TOOL_TYPE_STYLUS BUTTON_SECONDARY BUTTON_TERTIARY getPressure(), getSize(), getOrientation(), etc. Until now, this only worked for wired/builtin digitizers
  60. 60. Bluetooth stylus support Want to make a Bluetooth stylus? Report pressure and buttons using Bluetooth HID Android M will fuse this with touch events Result touch stream will be TOOL_TYPE_STYLUS (or TOOL_TYPE_ERASER) Bluetooth stylus support for every app and every M device
  61. 61. New stylus API in M Button support ACTION_BUTTON_PRESS, ACTION_BUTTON_RELEASE, BUTTON_STYLUS_PRIMARY, BUTTON_STYLUS_SECONDARY Gesture support ScaleGestureDetector.setStylusScaleEnabled(bool) Quick scale with button-click+drag OnGestureListener.onStylusButtonPress Use this for selection & drag-and-drop
  62. 62. Graphics & Media IT’S ALL ABOUT THE PIXELS
  63. 63. RenderScript Compute BLAS intrinsics (Really big matrices) Allocation-less launches Size of kernel separate from data ScriptGroup More dependency types Better compiler optimizations
  64. 64. Camera New Torch mode Independent of camera device CameraManager.setTorchMode(String cameraId, boolean enabled); public abstract class CameraManager.TorchCallback { public void onTorchModeUnavailable(String cameraId) {} public void onTorchModeChanged(String cameraId, boolean enabled) {} }
  65. 65. Alpha Optimization Auto hardware layer for translucent Views Call setLayerType() yourself still a Good idea
  66. 66. MIDI Your could already do this… … but it was a lot of work Introducing … android.media.midi MidiDeviceManager MidiInputPort MidiOutputPort MidiDeviceService
  67. 67. High Resolution Audio Audio samples: single-precision float Sample rate: 96 kHz USB digital audio: multichannel
  68. 68. Tools MAKE IT HAPPENS
  69. 69. Android Studio Integrated testing support Data binding Vector drawables New annotations Android NDK
  70. 70. Systrace
  71. 71. Systrace ListView item recycling involved inflating views. Ensure Your Adapter#getView() recycles the incoming View, Instead of constructing a new one.
  72. 72. ART Compiler optimizations register allocator global value number loop-invariant code motion dead code elimination bounds check elimination constant folding inlining
  73. 73. ART Runtime stats Debug.getRuntimeStat(String) “art.gc.gc-count” “art.gc.gc-time” …
  74. 74. Misc REALLY IMPORTANT STUFF WE COULDN’T EASILY CATEGORIZE
  75. 75. External Storage “Adopt” permanent storage Avoid hard-coded paths No new APIs! For Preview testing: $ adb root && sleep 2 $ adb shell setprop persist.fw.force_adoptable 1 $ adb reboot
  76. 76. Developing for Android Guide for better mobile apps medium.com/google-developers
  77. 77. So what are you waiting for? Preview: d.android.com/preview SDK + Android Studio: d.android.com/sdk System image: d.android.com/sdk Report bugs: code.google.com/android-developer-preview DevBytes: youtube.com/GoogleDevelopers
  78. 78. Thank you Q&A

×