Android M Developer Preview-api Preview (i)

Source: Internet
Author: User

API Overview

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

The release of the upcoming Android platform will provide new features for users as well as app developers, and the M Developer Preview provides an overview. This document will introduce you to the most notable APIs.

The M Developer Preview is intended for Developer early adopters and testers. If you is interested in influencing the direction of the Android framework, give the M Developer Preview a try and send u S your feedback!

M Developer Preview for pre-development developers and testers. If you are interested in directly acting on Android Frameword, try the next m Developer Preview and send us your feedback!

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

Warning: Do not push apps that use the M Developer preview to the Google App Store.

Note: This document often refers to classes and methods that does not yet has reference material available on DEVELOPER.ANDROID.C Om. These API elements is formatted in the This code style document (without hyperlinks). For the preliminary API documentation for these elements, download the preview reference.

Note: This document often mentions classes and methods that do not have a corresponding reference material available on developer.android.com. These API tags are in the format of code styles (not hyperlinks) in this document. These tags correspond to the earlier API documentation that can be downloaded in preview reference.

Important behavior changes Important behavioral changes

If you have previously published a app for Android, is aware that your app might is affected by changes in the platform.

If you've previously pushed an app under an Android platform, you'll notice that your app may be affected by changes in behavior on the new platform.

Please see Behavior changes for complete information.

Please read the section on behavior changes for complete information.

app linking App links

This preview enhances Android's intent system by providing more powerful app linking. This feature allows your associate an app with a web domain for you own. Based on this association, the platform can determine the default app to the handle a particular web link and skip Prom Pting users to select an app. To learn how to implement this feature, see App linking.

The preview improves Android's intent system by providing more effective app links. This feature allows you to associate an app with one of your own web domain names. On the basis of this association, the new platform determines the default app for processing a particular web link and skips the steps that prompt the user to select an app. Check out the app linking to learn how to implement this feature.

Auto Backup for Apps apps automated backups

The system now performs automatic full data backup and restore for apps. For the duration of the M Developer Preview program, all apps is 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 don't 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-to-back-on the file system, see Auto Backup for Apps.

The Android platform now automatically backs up and restores all data to the app. During the operation of the M Developer Preview program, all apps are backed up and independent of 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 the behavior, without adding any additional code. If a user deletes their Google account, their data backup will be deleted as well. Learn how this feature works and how to set up data that will be backed up to the file system, see Auto Backup for Apps.

Authentication Authentication

This preview offers the new APIs to let you authenticate users by using the their fingerprint scans on supported devices, and CHEC K How recently the user is last authenticated using a device unlocking mechanism (such as a lockscreen password). Use these APIs on conjunction with the Android Keystore system.

To enable you to authenticate users with fingerprint scanning on a device that supports fingerprint identification, and to check how the last authenticated user used the device unlock mechanism (such as a lock screen password), the preview provides some new APIs, combined with Android Keystore System section to use these APIs.

Fingerprint Authentication fingerprint authentication

To authenticate users via fingerprint scan, get a instance of the new Fingerprintmanager class and call the Authenticate ( ) method. Your app must is running on a compatible device with a fingerprint sensor. You must implement the user interface for the fingerprint authentication flow in your app, and use the standard Android fi Ngerprint icon in your UI. The Android fingerprint icon ( c_fp_40px.png ) is included in the sample app. IF you're developing multiple apps that's use fingerprint authentication, note this each app must authenticate the user s F Ingerprint independently.

In order to authenticate the user through fingerprint scanning, we need to get an instance of the new class Fingerprintmanager and Call method Authenticate (). Your application must be running on a device that is compatible with the fingerprint sensor. In 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. The Android Fingerprint authentication icon ( c_fp_40px.png ) is included in the sample program. If you are developing multiple applications that use fingerprint authentication, be aware that each application must independently authenticate the user's fingerprint.

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

In order to use this feature in your app, you first need to add Use_fingerprint permissions to your inventory profile manifest:

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

To see a app implementation of fingerprint authentication, refer to the Fingerprint Dialog sample. For a demonstration of what can use these authentication APIs in conjunction with other Android APIs, see the video Fin Gerprint and Payment APIs.

To view a fingerprint-certified application implementation, consult the Fingerprint Dialog sample. Video fingerprint and Payment APIs, demonstrating how to use these authentication APIs together with other Android APIs.

If You is testing this feature, follow these steps:

If you are testing the feature, follow these steps:

    1. Install Android SDK Tools Revision 24.3.

Install android SDK Tools Revision 24.3 First, if you haven't finished this step yet.

    1. Enroll a new fingerprint in the emulator by going to Settings > Security > Fingerprintand then follow the ENR Ollment instructions.

In the simulator, click Settings > Security > Fingerprint to add a new fingerprint, then follow the fingerprint registration Guide to do it.

    1. Use a 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 an emulator 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, your may has to runtelnet 127.0.0.1

在Windows系统上,你可能需要运行如下命令:telnet 127.0.0.1

<emulator-id>followed by finger touch <finger_id> .

<emulator-id>紧跟finger touch <finger_id>之后。

Confirm Credential Confirmation voucher

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

Your application can authenticate users based on how the user last unlocked their device. This feature frees users from having to remember extra application-specific passwords, and also avoids the need for you to implement your own user authentication interface. For user authentication, your application should use this feature in conjunction with a public or private key implementation.

To set the timeout duration for which the same key can be re-used after a user was successfully authenticated, call the new Setuserauthenticationvaliditydurationseconds () method when you set up a keygenerator or keypairgenerator.

In order to set the time-out for the same key after a user has successfully authenticated, Call the new method when you build a keygenerator or Keypairgenerator setuserauthenticationvaliditydurationseconds ()

Avoid showing the re-authentication dialog excessively--your apps should 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 re-verifying the excessive display of the Identity dialog box, first your application should use the encrypted object whenever possible, and if the timeout expires, use Createconfirmdevicecredentialintent ()方法以在你的应用程序中重新验证用户身份。

To see a app implementation of this feature, refer to the CONFIRM credential sample.

To view the application implementation of this feature, consult confirm credential sample.

Direct Share share directly

This preview provides the sharing intuitive and quick for users. You can now define direct share targets , launch a specific activity in your app. These direct share targets is exposed to users via the share menu. This feature allows users to share content to targets, such as contacts, and within other apps. For example, the direct share target might launch a activity in another social network app, which lets the user share con Tent directly to a specific friend or community in that app.

This preview will give you some APIs that make sharing more intuitive and fast for your users. Now you can define a direct share component to launch a specific activity in your App . These direct-sharing components are exposed to the user through the Share menu. This feature allows users to share specific content to targets, such as contacts, in other applications. For example, a direct share component can launch an activity in other social networking apps, which will allow users to share specific content directly into a particular friend or community within those 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 Bind_chooser_target_service permission and an intent filter using the SERVICE_INTERFA CE action.

In order to enable the direct sharing component, you must define a inherit from choosertargetservice 的类。在清单文件manifest中定义你的服务。在该定义中,指定 bind_chooser_target_service 权限和一个使用 bind_chooser_target_ SERVICE动作的意图过滤器。

The following example shows how to might declare the choosertargetservice in your manifest.

The following example shows how to define Choosertargetservice in a manifest file.

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

For each activity this want to expose to Choosertargetservice, add a element with the <meta-data> name in "android.service.chooser.chooser_target_service" your app Ma Nifest.

For each one you want to expose to Choosertargetservice的activity,在你的清单文件中添加一个使用name为"android.service.chooser.chooser_target_service"的<meta-data>标签。

<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 speech interaction

This preview provides a new voice interaction API which, together and voice Actions, allows you to build conversational V Oice experiences into your apps. Call the Isvoiceinteraction () method to determine if a voice action triggered your activity. If So, your apps can use the Voiceinteractor class to request a voice confirmation from the user, select from a list of opt Ions, and more.

The preview provides a new voice interaction API that is the same as voice actions, allowing you to build a conversational voice experience in your application. Call Method Isvoiceinteraction () 以确定你的activity是否触发了一个语音活动。如果是,你的应用程序可以使用类 Voiceinteractor向用户请求语音确认,选择一系列选项,等等。

Most voice interactions originate from a user voice action. A Voice interaction activity can also, however, start without user input. For example, the 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 Isvoiceinte Ractionroot () method. If Another app launched your activity, the method returns false . Your app May and prompt the user to confirm that they intended this action.

Most voice interactions originate from a user's voice activity. A voice interaction activity can do the same, however, without user input. For example, another application that starts with a voice interaction can also send an intention to initiate a voice interaction. Call Method Isvoiceinteractionroot () to determine whether your activity was initiated by a user voice query or other voice interaction app. If another app launches your activity, the method returns false. Your app can then prompt the user to confirm their intentions for the event.

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

See section Voice Actions Developer site for more information on voice activity implementations.

Assist API-Assisted API

This preview offers a new-to-engage with your apps through an assistant. The 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 on the Home button.

This preview provides a new way for users to interact with your app through an assistant. In order to use this attribute, the user must enable the assistant using the current context. Once enabled, the user can invoke the assistant in any app by holding down the home button long.

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

Follow the steps below to add the assistant using the application's additional context.

    1. Implement the Application.onprovideassistdatalistener interface.

Implement Interface Application.onprovideassistdatalistener

    1. Register this listener by using Registeronprovideassistdatalistener ().

Using Registeronprovideassistdatalistener ()方法注册该监听器。

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

To be able to provide information specific to the activity Context Association, rewrite the callback function onprovideassistdata () 并有选择性地重写新的回调函数 onprovideassistcontent ()

 

Notifications Notice

This preview adds the following API changes for notifications:

The preview adds the following API changes to the notification:

    • New interruption_filter_alarms FILTER level, corresponds to the new ALARMS only does not disturb mode.

The new interruption_filter_alarms过滤器级别以符合新的Alarms only请勿打扰模式。

    • New Category_reminder CATEGORY value that's used to distinguish user-scheduled reminders from other events (Category_even T) and alarms (category_alarm).

New Category_reminder 类型值,用于区分用户定时提醒与其他的事件 (category_event) and alarm Clock (category_event).

    • New Icon class that can attach to your notifications 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 passed by Method Setsmallicon () 和方法 Setsmallicon ()将该类与通知相关联。

    • New getactivenotifications () method that allows your apps to find out which of their notifications is currently alive. To see a app implementation that uses this feature, see the Active Notifications sample

The new Method Getactivenotifications () ,允许你的应用程序找出在所有通知中当前活动的通知。查阅 Active notifications sample to see the application implementation used by the feature.

Bluetooth Stylus Support bluetooth® Stylus

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 screens is fused with pressure and buttons 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 an D Gesturedetector.oncontextclicklistener objects in your activity.

This preview provides an improved support for user input that uses a Bluetooth stylus. Users can match and connect a compatible Bluetooth stylus with their phone or tablet. When connected, the location information generated by the screen touch becomes stressful, and the button information generated by the stylus provides a larger range of representations than just touching the screen. By registering View.oncontextclicklistener View.oncontextclicklistener in activity 对象, , your application can listen to the stylus's buttons and pressure, performing secondary actions.

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

Using Motionevent类中的方法和变量来检测手写笔按钮活动:

If the user touches a stylus with a button on the screen of the Your app, the Gettooltype () method returns Tool_type_stylus.

If the user touches a stylus through a button on the application screen, Method Gettooltype () 会返回 Gettooltype ()

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 with M-preview as the target system, 方法 getbuttonstate () button_stylus_primary when the user presses the primary stylus button 会返回 。如果手写笔有第二个按钮,当用户按下该按钮时该方法会返回 button_stylus_ Secondary 。如果用户同事按下了两个按钮的话,该方法会同时返回这两个值相互或运算之后的值( button_stylus_primary| Button_stylus_secondary)。

Android M Developer Preview-api Preview (i)

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.