你的位置:首页 > 软件开发 > 操作系统 > Android M Developer Preview

Android M Developer Preview

发布时间:2015-09-06 20:00:08
API OverviewThe M Developer Preview gives you an advance look at the upcoming release for the Android platform, which offers new features fo ...

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.

即将到来的Android平台的释放版本将会为用户以及App开发者提供新的功能特性,M Developer Preview则为此提供一个预览。本文档将会向大家介绍大多数值得注意的APIs。

 

The M Developer Preview is intended for developer early adopters and testers. 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面向前期的开发人员和测试人员。如果你有意直接作用于Android frameword,不妨尝试下M Developer Preview,并向我们发送你的反馈!

 

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

警告:不要推送那些使用了M Developer Preview的应用到谷歌应用商店上去。

 

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 in code style in this document (without hyperlinks). For the preliminary API documentation for these elements, download the preview reference.

注意:本文档会经常提到在developer.android.com上还没有对应的可用参考材料的类和方法。本文档中这些API标记都是代码样式的格式(而不是超链接)。这些标签对应的早期的API文档,在preview reference中可以下载。

 

Important behavior changes重要的行为更改

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

如果你之前已经推送了一款Android平台下的App,你会发觉你的App可能会受到新平台中行为的更改而带来的影响。

 

Please see Behavior Changes for complete information.

请阅读行为更改章节获取完整的信息。

 

App Linking App 链接

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 particular web link and skip prompting users to select an app. To learn how to implement this feature, see App Linking.

该预览通过提供更多有效的App链接改善了Android的意图系统。该特性允许你通过你自己的一个web域名来关联某个app。在此关联的基础上,新平台会确定用于处理某一特定web链接的默认App,并跳过提示用户选择一款App的步骤。查阅App Linking,以学习如何实现该特性。

 

Auto Backup for Apps Apps自动备份

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.

现在的Android系统平台会自动地对App进行所有数据的备份和还原。M Developer Preview 程序运行期间,所有的App都会被备份,且与各个App的目标SDK版本无关。M SDK最终的预览版释放之后,你的App必须target到M以激活该行为;无须添加任何额外的代码。如果用户删除了他们的Google账户,他们的数据备份也会被删除。学习该特性的工作原理及如何设置将被被备份到文件系统上的数据,请查看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 mechanism (such as a lockscreen password). Use these APIs in conjunction with the Android Keystore system.

为了能够让你在支持指纹识别的设备上通过指纹扫描来进行用户身份验证,同时检查最近一次进行身份验证的用户是如何使用设备解锁机制的(例如锁屏密码),该预览版提供了一些新的APIs,结合Android Keystore system章节来使用这些API吧。

 

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.

为了通过指纹扫描进行用户身份验证,需获取新类FingerprintManager的一个实例并调用方法authenticate()。你的应用程序必须运行在一个兼容指纹感应器的设备上。在你的App上你必须为指纹认证流程实现一个用户界面,并且在应用UI中使用标准的Android指纹认证图标。Android指纹认证图标(c_fp_40px.png)包含在示例程序中。如果你正开发多个使用指纹认证的应用程序,需要注意每一个应用都必须独立地验证用户的指纹。

 

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

为了在你的App中使用该特性,首先需要在你的清单配置文件manifest中添加USE_FINGERPRINT权限:

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

如要查看一个指纹认证的应用程序实现,请查阅Fingerprint Dialog sample.视频Fingerprint and Payment APIs,示范了如何结合使用这些身份验证APIs以及其他的Android APIs。

 

If you are testing this feature, follow these steps:

如果你正在测试该特性,那么跟随如下步骤:

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

先安装Android SDK Tools Revision 24.3,如果你还没有完成这一步的话。

  1. Enroll a new fingerprint in the emulator by going to Settings > Security > Fingerprint, then follow the enrollment instructions.

在模拟器中依次点击设置>安全>指纹以添加一个新的指纹,之后按照指纹登记指南来做即可。

  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.

使用一个模拟器及如下命令来模拟指纹触摸事件。使用同样的命令在屏幕上面或者在你的应用程序中模拟指纹触摸事件。

adb -e emu finger touch <finger_id>

On Windows, you may have to run telnet 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 确认凭证

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 should use this feature in conjunction with a public or secret key implementation for user authentication.

你的应用程序可以基于用户最近一次解锁其设备的方式来进行用户身份验证。该特性使用户从不得不记住额外的特定于应用程序的密码中解脱出来,同时也避免了你来实现自己的用户身份验证界面的必要。对于用户身份验证而言,你的应用程序应该将该特性同一个公开的或者私密的密钥实现一块协同使用。

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.

为了设置相同的Key在某个用户成功进行身份验证之后的超时时间,当你搭建一个KeyGenerator或者KeyPairGenerator时调用新方法setUserAuthenticationValidityDurationSeconds()

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

为了避免重新验证身份对话框的过度显示,首先你的应用程序应当尽可能的使用加密对象,如果超时失效了,使用createConfirmDeviceCredentialIntent()方法以在你的应用程序中重新验证用户身份。

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

查看该特性的应用程序实现,请查阅Confirm Credential sample。

Direct Share 直接分享

This preview provides you with APIs to make sharing intuitive and quick for users. You can now define direct share targets that launch a specific activity in your app. These direct share targets are exposed to users via the Share menu. 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.

该预览会向你提供一些让分享对用户而言更直观快速的APIs。现在你可以定义直接分享组件,以在你的App中启动某个特定的activity。这些直接分享组件会通过分享菜单暴露给用户。该特性允许用户在其它应用程序中分享特定内容到targets,诸如联系人等。例如,直接分享组件可以启动其它社交网络类App中的某个activity,这将让用户能够在这些应用程序中直接分享特定内容到某个特定的朋友或者社区中。

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_INTERFACE action.

为了启用直接分享组件,你必须定义一个继承自ChooserTargetService的类。在清单文件manifest中定义你的服务。在该定义中,指定BIND_CHOOSER_TARGET_SERVICE权限和一个使用BIND_CHOOSER_TARGET_SERVICE动作的意图过滤器。

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

如下示例展示了如何在清单文件中定义ChooserTargetService.

<service android:name=".ChooserTargetService"

 

海外公司注册、海外银行开户、跨境平台代入驻、VAT、EPR等知识和在线办理:https://www.xlkjsw.com

原标题:Android M Developer Preview

关键词:Android

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

可能感兴趣文章

我的浏览记录