![Page 1: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/1.jpg)
What’s New in Android
+Adam Koch
+Ankur Kotwal
![Page 2: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/2.jpg)
AgendaAndroid M ReleaseGoogle Play Services v7.8Android Tools & Libraries
![Page 3: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/3.jpg)
Android M
![Page 4: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/4.jpg)
Android M…?
![Page 6: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/6.jpg)
Android Marshmallow
![Page 7: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/7.jpg)
Available now for Nexus 5/6/9, Player & emulator
developer.android.com/preview
Get your apps ready!
Provide feedback and report bugs
Issue tracker: goo.gl/zcjEj7
Google+ community: goo.gl/BIq1eJ
Android M Developer Preview
![Page 8: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/8.jpg)
On August 17 we released:
- Developer Preview 3 ROMs
- Final Android 6.0 (Marshmallow) SDK
Start publishing to Play today!
M Preview Timeline You are here
![Page 9: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/9.jpg)
Getting Started with Marshmallow
android {
compileSdkVersion 23
buildToolsVersion '23.0.0'
defaultConfig {
applicationId 'com.google.samples.apps.mpreviewtest'
minSdkVersion 23
targetSdkVersion 23
versionCode 1
versionName '1.0'
}
}
![Page 10: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/10.jpg)
Runtime permissions!
Auto Backup
Power-Saving Optimizations
Other behavior changes:- Adoptable Storage Devices
- AndroidHttpClient -> HttpUrlConnection
- OpenSSL -> BoringSSL
- And more: goo.gl/cf4lwy
Android M Behavior Changes
![Page 11: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/11.jpg)
Why should you care?
- Significantly different behavior (after targeting M)
- No permission dialog on install --> less friction
- App updates --> automatic
- Fine grained, revocable permissions --> user feels in
control, improved user experience
Runtime Permissions
![Page 12: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/12.jpg)
targetSdkVersion < M targetSdkVersion = M+
Pre-M deviceInstall time permission dialog
All permissions granted
M deviceInstall time permission dialog
All permissions grantedUser can revoke permissions
No dialog during installNo permissions granted initially
App can request permissionsUser can revoke permissions
Runtime Permissions
![Page 13: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/13.jpg)
Runtime Permissions
Location
Camera
Microphone
Phone
All location permissions
Photo and video permissions
Audio recording
Phone state, dialing, etc.
SMS
Contacts
Calendar
Sensors
Storage
Controlling or reading SMS/MMS/etc.
Managing contacts
Managing calendars
Body sensors
Read, write external storage
![Page 14: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/14.jpg)
Best Practices
Only ask for what you need, when you need it
Don’t overwhelm the user
Consider using system Intents if possible
Explain why you need permissions
Runtime Permissions
![Page 15: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/15.jpg)
![Page 16: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/16.jpg)
![Page 17: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/17.jpg)
Context.checkSelfPermission(String permission)
Activity.requestPermissions(
String[] permissions, int requestCode)
Activity.onRequestPermissionsResult(
int requestCode, String[] permissions,
int[] grantResults)
New permissions methods
ContextCompat.checkSelfPermission(String permission)
ActivityCompat.requestPermissions(
String[] permissions, int requestCode)
ActivityCompat.onRequestPermissionsResult(
int requestCode, String[] permissions,
int[] grantResults)
*Also in Support Library (v23)
![Page 18: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/18.jpg)
static final int LOCATION_PERMISSION_REQUEST_RESULT = 2;
...
if (checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED) {
requestPermissions(
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
LOCATION_PERMISSION_REQUEST_RESULT);
}
Requesting a permission
![Page 19: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/19.jpg)
@Override
public void onRequestPermissionsResult(
int requestCode, String[] permissions, int[] grantResults) {
switch (requestCode) {
case LOCATION_PERMISSION_REQUEST_RESULT: {
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// Granted!
} else {
// Denied!
}
}
}
}
Checking if permission was granted
![Page 20: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/20.jpg)
If shouldShowRequestPermissionRationale()
returns true then show your own in-app UI
explaining why you need the permission.
When does it return true? If the user has denied the
permission in the past (but NOT checked “Don’t ask
again”).
Showing your own explaination
![Page 21: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/21.jpg)
Free and automatic app data backup (and restore)
Up to 25MB per user per app
Occurs every 24 hours
Enabled for *all* apps running on M Preview (but for
M final only targetSdkVersion=M)
Auto Backup for Apps
![Page 22: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/22.jpg)
Use platform APIs correctly, don’t hardcode paths:getFilesDir(), getExternalFilesDir(), etc. will be backed up
getCacheDir(), getExternalCacheDir(), etc. will not be backed up
Exclude device-specific identifiers from backup(eg. GCM registration ID, etc.)
Auto Backup for Apps
![Page 23: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/23.jpg)
Configuring Auto BackupAndroidManifest.xml
<application ...
android:fullBackupContent="@xml/mybackupscheme" />
xml/mybackupscheme.xml
<full-backup-content>
<include domain=["file"|"database"|"sharedpref"|"external"|"root"] path="string" />
<exclude domain=["file"|"database"|"sharedpref"|"external"|"root"] path="string" />
</full-backup-content>
![Page 24: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/24.jpg)
# enable logging
$ adb shell setprop log.tag.BackupXmlParserLogging VERBOSE
# initialize Backup Manager
$ adb shell bmgr run
# trigger backup or restore
$ adb shell bmgr fullbackup <PACKAGE>
$ adb shell bmgr restore <PACKAGE>
Testing Auto Backup
![Page 25: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/25.jpg)
Doze
increase standby time of devices
that aren’t being used
App Standby
reduce overhead of apps that are
installed but not used recently
Power-Saving Optimizations
flickr/trophygeek
![Page 26: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/26.jpg)
Network access disabled (except high priority GCM)
Wake locks are ignored except for alarms set with setAlarmClock()
and setAndAllowWhileIdle()
Syncs and JobScheduler tasks are not allowed to run
Test with:
Doze
$ adb shell dumpsys battery unplug
$ adb shell dumpsys deviceidle step
$ adb shell dumpsys deviceidle -h
![Page 27: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/27.jpg)
Apps considered idle unless:- explicitly launched by user
- has a foreground process
- visible notification
- user asks for the app to be exempt
Idle apps are restricted:- network access disabled
- syncs and background jobs suspended
App Standby
![Page 28: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/28.jpg)
Android M New Platform Features
Direct Share
Fingerprint API & Confirm Credentials
Voice Interactions & Assist API
App Linking
Text Selection
And much more:- Bluetooth Stylus, 4K Display, MIDI, Camera,
Android for Work...
![Page 29: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/29.jpg)
Other Smaller Additions
![Page 30: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/30.jpg)
Other Small Additions
After:<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:foreground="@drawable/selector">
...
</LinearLayout>
Before:<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:foreground="@drawable/selector">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
...
</LinearLayout>
</FrameLayout>
![Page 31: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/31.jpg)
Other Small Additions
Notifications
New android.graphics.drawable.Icon,
- Icon.createWithBitmap(Bitmap) for dynamic icons
Notification.Builder.setSmall/LargeIcon(Icon)
getActiveNotifications()
![Page 32: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/32.jpg)
And lots more...
Fingerprint API & Confirm Credentials
Voice Interactions & Assist API
App Linking
Text Selection
Bluetooth Stylus
4K Display
MIDI
Camera
Android for Work…
Themeable ColorStateLists
![Page 33: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/33.jpg)
Google Play Services v7.8
![Page 34: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/34.jpg)
Nearby Messages
Find nearby devices or beacons and
share messages
Cross platform supportAndroid & iOS
Unauthenticated(Does not require a Google account)
Uses a variety of tech under the hoodBluetooth, Bluetooth Low Energy, Wi-Fi and an
ultrasonic modem
![Page 35: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/35.jpg)
Face API & Barcode API
Mobile Vision API
![Page 36: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/36.jpg)
Smart Lock for Passwords
Credentials API● auth.credentials.save
● auth.credentials.request
com.google.android.gms.auth.api.c
redentials.CredentialsApi
![Page 37: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/37.jpg)
Creates a unique ID per app per install
Generate security tokens for services (suited for user by GCM)
Verify app authenticity & check if app install is active via web API
InstanceID
// Get InstanceID
String iid = InstanceID.getInstance().getID();
![Page 38: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/38.jpg)
Topic based subscriptions
New base classes for receiving GCM messages
GCM Network Manager
Google Cloud Messaging
![Page 39: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/39.jpg)
GCM Network ManagerGcmNetworkManager JobScheduler
Run during specifictime window
Supported(one off, periodic)
Supported(one off, periodic)
Require device charging Supported Supported
Specify network type Supported Supported
Require device idle Not Supported Supported
Execute by deadline Not Supported Supported
![Page 40: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/40.jpg)
Android Tools & Libraries
![Page 41: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/41.jpg)
C/C++ support (coming soon)- integrated debugging,
code completion, refactoring
Debugger improvements
Separate unit testing module
Speed improvements
Visual theme editor, layout editor improvements
Android Studio
![Page 42: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/42.jpg)
Android Studio
![Page 43: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/43.jpg)
Drawable ResourcesBitmap Vector
![Page 44: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/44.jpg)
compile 'com.android.support:design:23.0.0'
Android Design Support Library
![Page 45: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/45.jpg)
Floating labels for hint and error text
Built-in animations
Wrap EditText in a TextInputLayout
TextInputLayout
![Page 46: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/46.jpg)
Providing lightweight quick feedback to your users
Snackbar
.make(parentLayout, “My Text”, Snackbar.LENGTH_LONG)
.setAction(“My Action”, myOnClickListener)
.show(); //Don’t forget to show!
Snackbar
![Page 47: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/47.jpg)
Top level navigation or grouping content
tabGravity = center, fill
tabMode = scrollable, fixed
TabLayout
![Page 48: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/48.jpg)
● Component to create view inside Navigation Drawer
● Used with DrawerLayout
● Load items from menu resources
NavigationView
![Page 49: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/49.jpg)
Built-in component for FAB, follows design spec
Default color = ?attr/colorAccent
fabSize = full, mini
Floating Action Button (FAB)
![Page 50: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/50.jpg)
Provide additional level of control between child
views
Coordinate different Views- FloatingActionButton
- Snackbar
- Toolbar, Tabs
Each View sets own behavior- CoordinatorLayout.Behavior
CoordinatorLayout
![Page 51: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/51.jpg)
compile 'com.android.support:percent:23.0.0'
Managing percent based dimensions
<android.support.percent.PercentFrameLayout ...>
<ImageView app:layout_widthPercent="50%"
app:layout_heightPercent="50%"
app:layout_marginTopPercent="25%"
app:layout_marginLeftPercent="25%"/>
</android.support.percent.PercentFrameLayout>
Percent Support Library
![Page 52: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/52.jpg)
Placing a FAB - Before
private void addFloatingActionButton() {
final int fabSize =
getResources().getDimensionPixelSize(R.dimen.fab_size);
int bottomOfQuestionView =
findViewById(R.id.question_view).getBottom();
final LayoutParams fabLayoutParams =
new LayoutParams(fabSize, fabSize, Gravity.END | Gravity.TOP);
final int fabPadding =
getResources().getDimensionPixelSize(R.dimen.padding_fab);
final int halfAFab = fabSize / 2;
fabLayoutParams.setMargins(0, // left
bottomOfQuestionView - halfAFab, //top
0, // right
fabPadding); // bottom
addView(mSubmitAnswer, fabLayoutParams);
}
![Page 53: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/53.jpg)
<android.support.design.widget.CoordinatorLayout ...>
<TextView android:id="@+id/textLayout" />
<android.support.design.widget.FloatingActionButton ...
android:src="@drawable/ic_action_map"
app:layout_anchor="@id/textLayout"
app:layout_anchorGravity="bottom|start" />
</android.support.design.widget.CoordinatorLayout>
Placing a FAB - After
![Page 54: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/54.jpg)
Android Developer Blog Post
goo.gl/THH9OA
DevByte Video
goo.gl/0jhXFb
Cheesesquare Sample
github.com/chrisbanes/cheesesquare
Resources
![Page 55: Whats new in android jakarta gdg (2015-08-26)](https://reader034.vdocuments.us/reader034/viewer/2022052406/589f3d281a28ab490c8b5649/html5/thumbnails/55.jpg)
Thank You!
Questions?
+Adam Koch +Ankur Kotwal