Android M Developer Preview, androiddeveloper

Source: Internet
Author: User

Android M Developer Preview, androiddeveloper
API Overview

The M Developer Preview gives you an advance look at the upcoming release for the Android platform, which offers new features for users and app developers. This document provides an introduction to the most notable APIs.

The release of the coming Android platform will provide new features for users and App developers, and M Developer Preview will provide a Preview for this purpose. This document will introduce most noteworthy APIs.

 

The M Developer Preview is intendedDeveloper early adoptersAndTesters. If you are interested in influencing the direction of the Android framework, give the M Developer Preview a try and send us your feedback!

M Developer Preview is intended for early developers and testers. If you intend to directly act on Android frameword, try M Developer Preview and send your feedback to us!

 

Caution:Do not publish apps that use the M Developer Preview to the Google Play store.

Warning do not push apps that use M Developer Preview to the Google App Store.

 

Note:This document often refers to classes and methods that do not yet have reference material available on developer.android.com. These API elements are formatted incode styleIn this document (without hyperlinks). For the preliminary API documentation for these elements, download the preview reference.

Note: This document will often mention the absence of corresponding classes and methods for reference materials available on pai.android.com. In this document, these API tags are in the Code style format (rather than hyperlinks ). Early API documents corresponding to these tags can be downloaded in preview reference.

 

Important behavior changes

If you have previusly published an app for Android, be aware that your app might be affected by changes in the platform.

If you have already pushed an App on the Android platform, you will find that your App may be affected by changes in the behavior of the new platform.

 

Please see Behavior Changes for complete information.

Please readBehavior ChangeChapter to obtain complete information.

 

App Linking AppLink

This preview enhances Android's intent system by providing more powerful app linking. this feature allows you to associate an app with a web domain you own. based on this association, the platform can determine the default app to use to handle a participant web link and skip prompting users to select an app. to learn how to implement this feature, see App Linking.

This preview improves the Android intent system by providing more effective App links. This feature allows you to associate an app with your own web domain name. Based on this association, the new platform determines the default App used to process a specific web link, and skips the step of prompting you to select an App. Check the App Linking to learn how to implement this feature.

 

Auto Backup for Apps automatic Backup

The system now performs automatic full data backup and restore for apps. for the duration of the M Developer Preview program, all apps are backed up, independent of which SDK version they target. after the final m sdk release, your app must target M to enable this behavior; you do not need to add any additional code. if users delete their Google accounts, their backup data is deleted as well. to learn how this feature works and how to configure what to back up on the file system, see Auto Backup for Apps.

The current Android system automatically backs up and restores all data in the App. During the M Developer Preview program, all apps are backed up and irrelevant to the target SDK version of each App. After the final preview version of the m sdk is released, your App must target to M to activate this behavior. No additional code is required. If users delete their Google accounts, their data backups will also be deleted. To learn how this feature works and how to set the data that will be backed up to the file system, see Auto Backup for Apps.

Authentication

This preview offers new APIs to let you authenticate users by using their fingerprint scans on supported devices, and check how recently the user was last authenticated using a device unlocking mechanisms (such as a lockscreen password ). use these APIs in conjunction with the Android Keystore system.

To enable you to perform fingerprint scanning on a device that supports fingerprint recognition for user authentication, check how the last user used the device unlock mechanism (such as the lock screen password) for identity authentication. This preview provides some new APIs, use these APIs in conjunction with the Android Keystore system chapter.

 

Fingerprint Authentication

To authenticate users via fingerprint scan, get an instance of the new FingerprintManager class and call the authenticate () method. your app must be running on a compatible device with a fingerprint sensor. you must implement the user interface for the fingerprint authentication flow on your app, and use the standard Android fingerprint icon in your UI. the Android fingerprint icon (c_fp_40px.png) Is included in the sample app. If you are developing multiple apps that use fingerprint authentication, note that each app must authenticate the user's fingerprint independently.

To perform user authentication through fingerprint scanning, You need to obtain an instance of the new FingerprintManager class and call the authenticate () method (). Your application must run on a device compatible with fingerprint sensors. On your App, you must implement a user interface for the fingerprint authentication process and use the standard Android Fingerprint Authentication icon in the App UI. Android Fingerprint Authentication icon (c_fp_40px.png) Included in the sample program. If you are developing multiple applications that use Fingerprint Authentication, note that each application must verify the user's fingerprint independently.

 

To use this feature in your app, first add the USE_FINGERPRINT permission in your manifest.

To use this feature in your App, you must first add the USE_FINGERPRINT permission to the manifest configuration file:

<Uses-permission android: name = "android. permission. USE_FINGERPRINT"/>

 

To see an app implementation of fingerprint authentication, refer to the Fingerprint Dialog sample. for a demonstration of how you can use these authentication APIs in conjunction with other Android APIs, see the video Fingerprint and Payment APIs.

To view the implementation of a Fingerprint authentication application, see Fingerprint Dialog sample. Video Fingerprint and Payment APIs to demonstrate how to use these identities to authenticate APIs and Other Android APIs.

 

If you are testing this feature, follow these steps:

If you are testing this feature, follow these steps:

  1. Install Android SDK Tools Revision 24.3, if you have not done so.

First install Android SDK Tools Revision 24.3, if you have not completed this step.

  1. Enroll a new fingerprint in the emulator by goingSettings> Security> Fingerprint, Then follow the enrollment instructions.

In the simulator, choose Settings> Security> fingerprint to add a new fingerprint. Then, follow the fingerprint Registration Guide.

  1. Use an emulator to emulate fingerprint touch events with the following command. Use the same command to emulate fingerprint touch events on the lockscreen or in your app.

Use a simulator and the following command to simulate a fingerprint touch event. Use the same command to simulate a fingerprint touch event on the screen or in your application.

adb -e emu finger touch <finger_id>

On Windows, you may have to runtelnet 127.0.0.1

On Windows, you may need to run the following command: telnet 127.0.0.1

<emulator-id>Followedfinger touch <finger_id>.

<emulator-id>Follow finger touch <finger_id>.

Confirm Credential confirmation Credential

Your app can authenticate users based on how recently they last unlocked their device. this feature frees users from having to remember additional app-specific passwords, and avoids the need for you to implement your own authentication user interface. your app shocould use this feature in conjunction with a public or secret key implementation for user authentication.

Your application can perform user authentication based on the last time the user unlocked his/her device. This feature frees users from having to remember additional application-specific passwords and avoids the need for you to implement your own user identity authentication interface. For user authentication, your application should implement the same public or private key for collaborative use.

To set the timeout duration for which the same key can be re-used after a user is successfully authenticated, call the new setUserAuthenticationValidityDurationSeconds () method when you set up a KeyGenerator or KeyPairGenerator.

To set the timeout time for the same Key after a user successfully performs authentication, When you build a KeyGenerator or KeyPairGenerator, call the new method setUserAuthenticationValidityDurationSeconds ()

Avoid showing the re-authentication dialog excessively -- your apps shocould try using the cryptographic object first and if the timeout expires, use the createConfirmDeviceCredentialIntent () method to re-authenticate the user within your app.

To avoid excessive display of the re-authentication dialog box, first, your application should try to use the encrypted object. If the timeout expires, use createConfirmDeviceCredentialIntent ()Method to re-authenticate the user identity in your application.

To see an app implementation of this feature, refer to the Confirm Credential sample.

For more information about the application implementation of this feature, see Confirm Credential sample.

Direct Share

This preview provides you with APIs to make sharing intuitive and quick for users. You can now defineDirect share targetsThat launch a specific activity in your app. These direct share targets are exposed to users viaShareMenu. this feature allows users to share content to targets, such as contacts, within other apps. for example, the direct share target might launch an activity in another social network app, which lets the user share content directly to a specific friend or community in that app.

This preview will provide you with some APIs that make sharing more intuitive and fast for users. Now you can defineShare components directlyToAppTo start a specificActivity. These direct sharing components are exposed to users through the sharing menu. This feature allows users to share specific content in other applicationsTargets, Such as contacts. For example, share directlyThe component can start an activity in other social network apps, which enables users to directly share specific content to a specific friend or community in these applications.

To enable direct share targets you must define a class that extends the ChooserTargetService class. Declare your service in the manifest. Within that declaration, specify the specified permission and an intent filter using the SERVICE_INTERFACE action.

To enable the direct share component, you must define an inheritedClassChooserTargetService. Define your service in the manifest file. In this definition, specifyBIND_CHOOSER_TARGET_SERVICEPermission and useBIND_CHOOSER_TARGET_SERVICEAction intent filter.

The following example shows how you might declare the ChooserTargetService in your manifest.

The following example shows how to define ChooserTargetService in the configuration file..

<service android:name=".ChooserTargetService"
android:label="@string/service_name"
android:permission="android.permission.BIND_CHOOSER_TARGET_SERVICE">
 <intent-filter>
  <action
android:name="android.service.chooser.ChooserTargetService"/>
 </intent-filter>
</service>

For each activity that you want to expose to ChooserTargetService, add<meta-data>Element with the name"android.service.chooser.chooser_target_service"In your app manifest.

For each ChooserTargetService you want to exposeAdd a <meta-data> label named "android. service. chooser. chooser_target_service" in your configuration file.

<activity android:name=".MyShareActivity”
        android:label="@string/share_activity_label">
 <intent-filter>
        <action android:name="android.intent.action.SEND" />
 </intent-filter>
  <meta-data
     android:name="android.service.chooser.chooser_target_service"
     android:value=".ChooserTargetService" />
</activity>
Voice Interactions Voice Interaction

This preview provides a new voice interaction API which, together with Voice Actions, allows you to build conversational voice experiences into your apps. call the isVoiceInteraction () method to determine if a voice action triggered your activity. if so, your app can use the VoiceInteractor class to request a voice confirmation from the user, select from a list of options, and more.

This preview provides a new Voice interaction API, which is the same as Voice Actions and allows you to build a conversational Voice experience in applications. Call method isVoiceInteraction ()To determine whether your activity triggers a voice activity. If yes, your application can use the classVoiceInteractorRequest voice confirmation from the user, select a series of options, and so on.

Most voice interactions originate from a user voice action. A voice interaction activity can also, however, start without user input. for example, another app launched through a voice interaction can also send an intent to launch a voice interaction. to determine if your activity launched from a user voice query or from another voice interaction app, call the isVoiceInteractionRoot () method. if another app launched your activity, the method returnsfalse. Your app may then prompt the user to confirm that they intended this action.

Most speech interactions come from a user's speech activity. This is also true for a speech interaction activity. However, user input is not required. For example, another application started through a voice interaction can also send an intent to start a voice interaction. Call method isVoiceInteractionRoot ()To determine whether your activity is started by a user's voice query or other voice interaction App. If another App starts your activity, this method returns false. Your App then prompts users to confirm their plans for the activity.

To learn more about implementing voice actions, see the Voice Actions developer site.

View Voice Actions developer site to learn more about speech activity implementation.

Assist API-assisted APIs

This preview offers a new way for users to engage with your apps through an assistant. to use this feature, the user must enable the assistant to use the current context. once enabled, the user can summon the assistant within any app, by long-pressing onHomeButton.

This preview provides users with a new way to interact with your App through an assistant. To use this feature, you must enable the current context to use this assistant. Once enabled, you can call this assistant in any App by holding down the Home button.

 

To provide the assistant with additional context from your app, follow these steps:

Follow these steps to add the assistant by using the additional context of the application.

  1. Implement the Application. onprovide1_datalistener interface.

Implementation interface Application. onprovide1_datalistener

  1. Register this listener by using registeronprovide1_datalistener ().

Use registeronprovide1_datalistener ()Method to register the listener.

  1. In order to provide activity-specific contextual information, override the onprovide1_data () callback and, optionally, the new onprovide1_content () callback.

To provide activity-specific contextual information, override the onprovide1_data () callback function ()And selectively rewrite the new callback function.Onprovide1_content ()

 

Notifications

This preview adds the following API changes for notifications:

This preview adds the following API changes to the notification:

  • New INTERRUPTION_FILTER_ALARMS filter level that corresponds to the newAlarms onlyDo not disturb mode.

New INTERRUPTION_FILTER_ALARMSThe filter level conforms to the new Alarms only do not disturb mode.

  • New CATEGORY_REMINDER category value that is used to distinguish user-scheduled reminders from other events (CATEGORY_EVENT) and alarms (CATEGORY_ALARM ).

New CATEGORY_REMINDERType value, used to distinguish between user scheduled reminders and other events(CATEGORY_EVENT) and alarm (CATEGORY_EVENT ).

  • New Icon class that you can attach to your configurations via the setSmallIcon () and setLargeIcon () methods. Similarly, the addAction () method now accepts an Icon object instead of a drawable resource ID.

The new Icon class can be setSmallIcon ()And MethodsSetSmallIcon ()Associate this type with notifications.

  • New getActiveNotifications () method that allows your apps to find out which of their configurations are currently alive. To see an app implementation that uses this feature, see the Active configurations sample

New Method getActiveNotifications ()Allows your application to find the notifications of the current activity in all notifications. ViewActive configurications sample to view the application implementation used by this feature.

Bluetooth Stylus Support Bluetooth pen Support

This preview provides improved support for user input using a Bluetooth stylus. users can pair and connect a compatible Bluetooth stylus with their phone or tablet. while connected, position information from the touch screen is fused with pressure and button information from the stylus to provide a greater range of expression than with the touch screen alone. your app can listen for stylus button presses and perform secondary actions, by registering View. onContextClickListener and GestureDetector. onContextClickListener objects in your activity.

This preview provides improved support for user input using a Bluetooth pen. Users can match and connect a compatible Bluetooth pen with their mobile phone or tablet. After the connection, the location information generated by the touch on the screen is converted into pressure, and the button information generated by the touch pen provides a larger scope of expression than the touch on the screen. By registering View. OnContextClickListener in the activityAndView. OnContextClickListenerObject,Your application can listen to the buttons and pressure of the pen and perform secondary actions.

Use the MotionEvent methods and constants to detect stylus button interactions:

Use MotionEventClass to detect the pen button activity:

If the user touches a stylus with a button on the screen of your app, the getTooltype () method returns TOOL_TYPE_STYLUS.

If you touch a pen using a button on the application screen, the getTooltype () method ()Will returnGetTooltype ()

For apps targeting M Preview, the getButtonState () method returns BUTTON_STYLUS_PRIMARY when the user presses the primary stylus button. if the stylus has a second button, the same method returns BUTTON_STYLUS_SECONDARY when the user presses it. if the user presses both buttons simultaneously, the method returns both values OR 'ed together (BUTTON_STYLUS_PRIMARY | BUTTON_STYLUS_SECONDARY ).

For applications that use M Preview as the target system, when you press the main pen buttonMethodGetButtonState ()Will returnBUTTON_STYLUS_PRIMARY. If the pen has a second button, this method returns when the user presses this button.BUTTON_STYLUS_SECONDARY. If a user presses two buttons, this method returns the values after mutual or operation (BUTTON_STYLUS_PRIMARY | BUTTON_STYLUS_SECONDARY)。

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.