what’s new in android [google i/o extended bangkok 2016]

Post on 16-Apr-2017

5.373 Views

Category:

Technology

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

What’s new in aNdroid

The Droid has no name

#GeekAlert

#teamAndroid

ConstraintLayout

Multi-Window: Split Screen

Freeform Mode

Multi-Window LifecycleOnly focused Activity is active.

The rest are in “Paused” state.

[Live Demo]

Multi-Window LifecycleDefault behavior:

Recreate the Activity upon resizing

Or handle it yourself:

<activity android:configChanges= “screenSize|smallestScreenSize|screenLayout|orientation" ...

Multi-Window: Split Screenandroid:resizeableActivity=["true" | "false"]

<activity android:name=".MyActivity"> <layout android:defaultHeight="500dp" android:defaultWidth="600dp“ android:minHeight="200dp" android:minWidth="200dp" android:gravity="top|end"/></activity>

Activity.isInMultiWindowMode()Activity.onMultiWindowModeChanged()

Multi-Window: Split ScreenIntent.FLAG_ACTIVITY_LAUNCH_ADJACENT

Multi-Window: Picture-in-Picture

Multi-Window: Picture-in-Picture<activity android:name=".MyActivity“ android:resizeableActivity="true“ android:supportsPictureInPicture="true" android:configChanges= “screenSize|smallestScreenSize|screenLayout|orientation" ...

Activity.enterPictureInPictureMode()

Activity.isInPictureInPictureMode()Activity.onPictureInPictureModeChanged()

Drag n’ DropView.startDragAndDrop() View.DRAG_FLAG_GLOBAL View.DRAG_FLAG_GLOBAL_URI_READ View.DRAG_FLAG_GLOBAL_URI_WRITE

View.cancelDragAndDrop()View.updateDragShadow()

android.view.DragAndDropPermissionsActivity.requestDragAndDropPermissions()

Notifications• New templates

Notifications• New templates• Bundled notifications

Notifications• New templates• Bundled notifications• Direct Reply [Live Demo]

Notifications• New templates• Bundled notifications• Direct Reply [Live Demo]• Custom View [Live Demo]

Notifications• New templates• Bundled notifications• Direct Reply [Live Demo]• Custom View [Live Demo]• Message Style

Quick Settings• Users: Choose your favorite tiles!• Reorder them, too• Top 5 become your

even-quicker-quick-settings

• [Live Demo]

Quick Settings• Developers: Create your own tiles!• Key classes:

android.service.quicksettings.TileServiceonTileAdded(), onTileRemoved()onStartListening(), onStopListening()onClick()

getQsTile() -> android.service.quicksettings.TilesetState(), setLabel(), setIcon()then, updateTile()

Quick Settings

<service android:name=".MyTileService" android:label="@string/starting_label" android:icon="@drawable/starting_icon" android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"> <intent-filter> <action android:name="android.service.quicksettings.action.QS_TILE" /> </intent-filter></service>

Display Size• User-determined display size

• All UI, not just text

• .85x – 1.45x• Avoid px• Ensure your app works well on sw320dp

Multi-Locale• User can select multiple languages

• And order them

• Also added new languages, variants

• [Live Demo]

DozeMarshmallow

The ~Extended~ Doze modeN

Doze in N

Doze• Marshmallow• Screen off, on battery, stationary• Restricts network, services, defers jobs, syncs, alarms

• N• All of the above, plus• Screen off, on battery, not stationary• Restricts network, defers jobs, syncs

Project SvelteConnectivityManager.CONNECTIVITY_ACTIONCamera.ACTION_NEW_PICTURECamera.ACTION_NEW_VIDEO

JobSchedulerJobScheduler.Builder.addTriggerContentUri();

Goodbye

Hello!

Data Saver

Data Saver Flowchart

Data Saver

getSystemService(Context.CONNECTIVITY_SERVICE);

ConnectivityManager.isActiveNetworkMetered();

ConnectivityManager.getRestrictBackgroundStatus();

Data Saver

Direct Boot

Direct Boot: App Storage Areas

Direct Boot: App Storage Areas

Direct Boot: App Storage Areas

Direct Boot

<receiver android:directBootAware="true" > ... <intent-filter> <action android:name="android.intent.action.LOCKED_BOOT_COMPLETED" /> <action android:name="android.intent.action.BOOT_COMPLETED" /></intent-filter></receiver>

Scoped Directory Access

StorageManager sm = (StorageManager)getSystemService(Context.STORAGE_SERVICE);

StorageVolume volume = sm.getPrimaryVolume();

Intent intent = volume.createAccessIntent(Environment.DIRECTORY_PICTURES);

startActivityForResult(intent, request_code);

Android for Work

Runtime• Faster interpreter• JIT

• Faster install times• Less space consumed on device• Faster reboots

• Apps use partial AOT• Only for hotspots

New Runtime Libraries• ICU4J• Unicode and globalization support• Subset exposed in android.icu

• Avoids conflicts with com.ibm.icu• Deprecated and unstable APIs omitted

• Functional Interface• java.util.function• java.util.stream

Java 8 Language Features• Require the Jack toolchain

android { ... defaultConfig { ... jackOptions { enabled true } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 }}

Lambdas• Implemented using anonymous class• Backward compatible with Gingerbread

Vertex[] v = new Vertex[100];// ...

Arrays.sort(v, (Vertex v1, Vertex v2) -> { return v1.length() - v2.length();});

Arrays.sort(v, (v1, v2) -> v1.length() - v2.length());

Arrays.sort(v, VertexFactory::compareVertices);

Default & Static Interface Methods• Not backward compatible

public interface Renderable { void draw(Canvas c);

default bool isHardwardAccelerated() { return false; }

static int getMaxTextureSize() { return 2048; }}

public interface FrameListener { default void onFrameStarted() { } default void onFrameEnded() { }}

Stream APIs• Not backward compatible

List<String> dictionary = ...

dictionary.stream() .filter(s -> s.contains("droid")) .sorted() .limit(10) .forEach(s -> Log.d(TAG, "I love the word " + s));

Repeating Annotations• Not backward compatible

@Schedule(metered=false, frequencyInHours=24)@Schedule(metered=true, frequencyInHours=1)public void fullSync() { ...}

Java Audio Latency• Previous releases reduced native latency• Lower latency AudioTrack (40-70ms reduction)

AudioAttributes attributes = new AudioAttributes.Builder() .setFlags(AudioAttributes.FLAG_LOW_LATENCY) .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC) .build();

• Dynamic resize of AudioTrack buffers• Underruns query

Renderscript• Single source

• Many kernels in a single file• Launch kernels from kernels

• Reduction kernels• Access multiple image buffers from video streams• Allocation.getByteBuffer() to reduce copies• Enhanced fp16 support

OpenGL ES 3.2• GLES 3.1 + Android extension pack

• Except EXT_texture_sRGB_decode

• Advanced blending equations• Tesselation shaders• Geometry shaders• ASTC (LDR)• Image atomics• Floating point framebuffers

Vulkan• Low-level, low-overhead, cross-platform 3D API• Asynchronous/multithreaded command generation• Intermediate shader binary format (SPIR-V)• Offline shaders compilation• Object-based API, no global state• Explicit memory management and synchronization• No error checking

adb shell• Returns remote process exit status• Pass-through stdin $ cat README | adb shell wc -l• Handles window size and terminal type• Improved command line tools (ls, etc.)• Improved performance (push, pull)

NDK• Clang 3.8• GCC 4.9• Switch to clang, GCC is deprecated!• ARM toolchains default to arm7 arch

VR

Activity.setVRModeEnabled(boolean);

https://developers.google.com/vr/android/

Support Library

Future is here

Support Library• Night Mode• Bottom Sheets• VectorDrawable / AnimatedVectorDrawable• RecyclerView• Design Support Library• Chrome Custom Tabs• etc.

Other UI Goodies• VectorDrawable performance improvements• Loading, rendering improved 20-90% in N

• FloatProperty / IntProperty

Android Instant Apps

Android Instant Apps• Sneak preview now

• Rolling out to developers over the next year

• Build inside Android Studio• Just a different build artifact

• Demos in the Play Sandbox

Android N Release Date

Go Get It!

Go Get It!

Learn: d.android.com/preview

Get: d.android.com/preview/setup-sdk.html

Report: d.android.com/preview/bug

Thank you

top related