i/o rewind 215: what's new in android

78
#IORewind What’s new in Android M nuuneoi

Upload: sittiphol-phanvilai

Post on 07-Aug-2015

1.202 views

Category:

Technology


1 download

TRANSCRIPT

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

#IORewind

What’s new in Android M

nuuneoi

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

#IORewind

MStands for ...

mmmm

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

#IORewind

MStands for ...

Preview

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

#IORewind

Building M Preview Apps

Android M is now available on SDK Manager

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

#IORewind

Building M Preview Apps

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

#IORewind

Previewssssss

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

#IORewind

OK. Let’s start.

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

#IORewind

Apps PermissionFASTER INSTALLS • SMOOTHER UPGRADES • MORE USER

CONTROL

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

#IORewind

Install-time permissions

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

#IORewind

Runtime permissions in M

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

#IORewind

User controls in M

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

#IORewind

Everything you’ve ever asked for

But now your app has to deal with it

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

#IORewind

Apps targeting M can: can ask for any permission at any timeLegacy apps will: get all permissions at install time, as beforeUsers can: deny any permissions upon request deny any permissions at any later time – even legacy appsTest!

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

#IORewind

Voice Interactions

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

#IORewind

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>

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

#IORewind

Voice Interactions

public class MyVoiceActivity extends AppCompatActivity {

@Override protected void onResume() { super.onResume(); if (isVoiceInteraction()) { // do stuff } else { finish(); } }

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

#IORewind

Voice Interactions

public class MyVoiceActivity extends AppCompatActivity {

@Override protected void onResume() { super.onResume(); if (isVoiceInteraction()) { String prompt = "..."; getVoiceInteractor().submitRequest( new Confirm(prompt)); } else { finish(); } }

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

#IORewind

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(); } }

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

#IORewind

FingerprintQUICK USER VERIFICATION

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

#IORewind

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

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

#IORewind

Android BackupRESTORATION SOFTWARE

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

#IORewind

Android Backup

All data now backed up by default targetSdk M

Optional scheme file in xml/ resource dir includes/excludes

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

#IORewind

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>

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

#IORewind

Google Play Services

7.5 AND COUNTING

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

#IORewind

GCM Network Manager

Like JobScheduler … but across releases

OneOffTaskPeriodicTask

Limit network requests to wifi, or charging, or …

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

#IORewind

Also…

Maps on Android WearApp InvitesCast Remote DisplaySmart Lock for Passwords…

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

#IORewind

PowerEVEN BETTER BATTERY LIFE

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

#IORewind

Power improvements

Better screen-off battery lifeDoze Untouched devices become “inactive” Wait longer to wake up for background tasks Resume normal operation when moved, used, or plugged inApp standby Unused apps lose network access Resume when launched/used or when plugged in

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

#IORewind

Assistant Support

CONTEXTUAL INFORMATION, WHEN THE USER NEEDS IT

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

#IORewind

Assistant Support

New APIs to provide the assistant with relevant data

See SDK docs: Activity.onProvideAssistData(Bundle) Application.OnProvideAssistDataListener

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

#IORewind

Data BindingBOUNDS AND DETERMINED

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

#IORewind

Data Binding

Connecting data and UI elements Automates listener creation, message sending, setters, …Pre-processed at build time

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

#IORewind

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>

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

#IORewind

UI FeaturesALL ABOUT YOU AND I

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

#IORewind

Android Design Support Library

Snackbar

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

#IORewind

Android Design Support Library

SnackbarFAB

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

#IORewind

Android Design Support Library

SnackbarFABCoordinatorLayout

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

#IORewind

Android Design Support Library

SnackbarFABCoordinatorLayoutTabLayout

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

#IORewind

Android Design Support Library

SnackbarFABCoordinatorLayoutTabLayoutTextInputLayout

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

#IORewind

Android Design Support Library

SnackbarFABCoordinatorLayoutTabLayoutTextInputLayoutNavigationView

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

#IORewind

Other UI Changes

RecyclerView ItemTouchHelper Swipe-to-dismiss

Drag & drop

WebView PostMessage

WebViewClient

WebSettings.setOffscreenPreRaster()

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

#IORewind

NotificationsHEY! YOU THERE! LOOK UP HERE!

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

#IORewind

android.graphics.drawable.Icon

Holds either: a drawable resource id

a Bitmap

a byte[] holding a PNG or JPEG

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

#IORewind

Icons in Notifications

Icon ic = Icon.createWithResource(context, R.drawable.ic_notification);Notification no = Notification.Builder(context) .setSmallIcon(ic) ... .build();

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

#IORewind

Icons in Notifications

Icon ic = Icon.createWithBitmap(iconBitmap);

Notification no = Notification.Builder(context) .setSmallIcon(ic) ... .build();

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

#IORewind

Text StuffsTEXT IS ALL AROUND

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

#IORewind

Text Selection

Easier SelectionFloating palette with action items Default for TextView

Other views set ActionMode.TYPE_FLOATING

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

#IORewind

Text Processing

<intent-filter> <action android:name="android.intent.action.PROCESS_TEXT"/></intent-filter>

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

#IORewind

Higher Quality Text Formatting

TextView.setBreakStrategy(int);

TextView.setHyphenationFrequency(int);

TextView.setIndents(int[] left, int[] right);

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

#IORewind

App LinksRELATIONSHIP BETWEEN APP AND WEB DOMAINS

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

#IORewind

App Links

Understand the relationshipbetween an app and web domainsowned by the same developer

d.android.com/preview/features/app-linking.html

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

#IORewind

[{  "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

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

#IORewind

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

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

#IORewind

<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

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

#IORewind

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

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

#IORewind

Direct ShareSHARING IS EVEN MORE AWESOME

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

#IORewind

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 }}

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

#IORewind

Stylus supportNOW THE PRESSURE IS REALLY ON

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

#IORewind

Styluses: supported sinceICE_CREAM_SANDWICHMotionEvent APIs: TOOL_TYPE_STYLUS BUTTON_SECONDARY BUTTON_TERTIARY getPressure(), getSize(), getOrientation(), etc.

Until now, this only worked for wired/builtin digitizers

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

#IORewind

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

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

#IORewind

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

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

#IORewind

Graphics & Media

IT’S ALL ABOUT THE PIXELS

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

#IORewind

RenderScript Compute

BLAS intrinsics (Really big matrices)

Allocation-less launches Size of kernel separate from data

ScriptGroup More dependency types

Better compiler optimizations

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

#IORewind

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) {}

}

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

#IORewind

Alpha Optimization

Auto hardware layer for translucent Views

Call setLayerType() yourself still a Good idea

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

#IORewind

MIDI

Your could already do this… … but it was a lot of work

Introducing … android.media.midi MidiDeviceManager MidiInputPort

MidiOutputPort

MidiDeviceService

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

#IORewind

High Resolution Audio

Audio samples: single-precision float

Sample rate: 96 kHz

USB digital audio: multichannel

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

#IORewind

ToolsMAKE IT HAPPENS

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

#IORewind

Android Studio

Integrated testing supportData bindingVector drawablesNew annotationsAndroid NDK

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

#IORewind

Systrace

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

#IORewind

Systrace

ListView item recycling involved inflating views. EnsureYour Adapter#getView() recycles the incoming View,Instead of constructing a new one.

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

#IORewind

ART

Compiler optimizations register allocator global value number loop-invariant code motion dead code elimination bounds check elimination constant folding inlining

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

#IORewind

ART

Runtime stats Debug.getRuntimeStat(String)

“art.gc.gc-count”

“art.gc.gc-time”

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

#IORewind

MiscREALLY IMPORTANT STUFF WE COULDN’T EASILY CATEGORIZE

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

#IORewind

External Storage

“Adopt” permanent storageAvoid hard-coded pathsNo new APIs!For Preview testing: $ adb root && sleep 2

$ adb shell setprop persist.fw.force_adoptable 1

$ adb reboot

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

#IORewind

Developing for Android

Guide for better mobile apps

medium.com/google-developers

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

#IORewind

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

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

#IORewind

Thank youQ&A