Android 安装程序Android setup

重要

弃用2020年3月之前发布的 Microsoft Rights Management Service SDK 版本;必须将使用早期版本的应用程序更新为使用三月2020版。Versions of the Microsoft Rights Management Service SDK released prior to March 2020 are deprecated; applications using earlier versions must be updated to use the March 2020 release. 有关完整详细信息,请参阅弃用通知For full details, see the deprecation notice.

不会为 Microsoft Rights Management 服务 SDK 规划进一步的增强功能。No further enhancements are planned for the Microsoft Rights Management Service SDK. 我们强烈建议采用Microsoft Information PROTECTION SDK进行分类、标记和保护服务。We strongly recommend adoption of the Microsoft Information Protection SDK for classification, labeling, and protection services.

Android 应用程序可以通过使用 Azure Active Directory Rights Management (AAD RM),利用 Microsoft Rights Management SDK 4.2 在其应用中启用集成信息保护。Android applications can use the Microsoft Rights Management SDK 4.2 to enable integrated information protection in their applications by using Azure Active Directory Rights Management (AAD RM ).

本主题将指导你完成环境设置过程,以创建自己的新应用。This topic will guide you through setting up your environment for creating your own new apps .

先决条件Prerequisites

我们建议在开发系统上安装以下软件:We recommend the following software on your development system:

  • Windows 或 OS X 操作系统,用于运行 Eclipse 开发环境。Windows or OS X operating system to run the Eclipse development environment.

  • 本指南假定你在使用从 Eclipse Juno 4.2 开始的 Eclipse SDK 并使用默认安装。This guide assumes that you are using the Eclipse SDK beginning with Eclipse Juno 4.2 and using a default installation.

  • 从 Java 1.6 开始的 Java。Java starting with Java 1.6.

  • Android 开发人员工具 (ADT) 插件Android Developer Tools (ADT) Plugin. 注意 - 可能会请你重新启动 Eclipse 以完成安装。NOTE - You might be asked to restart Eclipse to complete the installation.

  • 适用于 Android 的 MS RMS SDK 4.2 包。The MS RMS SDK 4.2 package for Android. 有关详细信息,请参阅入门For more information see, Get started.

    此 SDK 可以用于为 Android 4.0.3(API 级别 15)及更高版本进行开发。This SDK can be used to develop for Android 4.0.3 (API level 15) and later.

  • 身份验证库:我们建议使用 Azure AD 身份验证库 (ADAL)Authentication library: We recommend that you use the Azure AD Authentication Library (ADAL). 但是也可使用其他支持 OAuth 2.0 的身份验证库。However, other authentication libraries that support OAuth 2.0 can be used as well.

    有关详细信息,请参阅 ADAL for AndroidFor more information see, ADAL for Android

    注意  如果你的应用程序将不使用 ADAL 库作为 OAuth 2.0 身份验证库,你应该查看此 Android 指南,一些 java.security.securerandomNote  If your application will not be using the ADAL Library as the OAuth 2.0 authentication library, you should review this Android guidance, Some SecureRandom Thoughts.

有关 API 更新、发行说明和常见问题解答 (FAQ) 的信息,请阅读新增功能主题。Read the What's new topic for information about API updates, release notes, and frequently asked questions (FAQ).

可选Optional

我们的 UI 库可为不想创建自己的自定义 UI 的开发人员提供用于使用和保护操作的可重用 UI - 适用于 Android 的 UI 库和示例Our UI library provides re-usable UI for consumption and protection operations for developers who don’t want to create their own custom UI - UI Library and Sample app for Android.

配置开发环境Configuring your development environment

注意  MS RMS SDK 4.2 预览版:在此预览版本中,屏幕截图尚未更新,以显示 pathes 从 com/microsoft/protection 到 com/microsoft/rightsmanagment 的名称更改。Note  MS RMS SDK 4.2 Preview Release: In this preview release, the screen shots have not been updated to show the change in name of the pathes from com/microsoft/protection to com/microsoft/rightsmanagment. 不过文本已进行了更新。The text though, has been updated.

  • 打开 Eclipse 开发环境。Open the Eclipse development environment.

  • 若要创建新 Android 应用程序项目,请在 “文件” 菜单上,单击 “新建”,单击 “项目”,然后选择 “Android 应用程序项目”To create a new Android Application project, on the File menu, click New, click Project, and then select Android Application Project.

    创建新的 Android 应用程序

  • 输入应用程序名称。Enter the application name. 项目名称和包名称根据应用程序名称进行填充。The project name and package name is filled based on the application name.

  • 单击 “下一步”,然后选择要用于创建工作区的位置。Click Next and select where you want to create the workspace.

    输入应用程序名称

  • 单击 “下一步”,然后为应用选择图标。Click Next and select an icon for your app.

    为应用选择图标

  • 单击 “下一步”,然后选择 “空白活动” 以创建活动。Click Next and select Blank Activity to create the activity.

    创建活动

  • 单击 “下一步” 并提供活动的名称。Click Next and provide a name for the activity. 可以将MainActivity保留为默认名称,其中布局名称为 "活动_主"。You can leave MainActivity as the default name with a layout name of activity_main.

    提供活动的名称

  • 单击“完成” 。Click Finish.

    完成创建

  • 项目以及主活动类 MainActivity.java 已创建。Your project has been created, along with the main activity class MainActivity.java.

引用 SDKReferencing the SDK

  • 导航到已在其中提取*_adrms android_sdk的文件夹。Navigate to the folder in which you extracted the adrms_android_sdk.zip. 在“SDK > com > microsoft > rightsmanagement”文件夹中,确保文件 .classpath.project* 和 project.properties 未标记为只读。In the "SDK > com > microsoft > rightsmanagement" folder, make sure the files .classpath, .project, and project.properties are not marked as read-only.

  • 若要引用 SDK,必须将它导入工作区中。To reference the SDK, you must import it to the workspace.

    在 Eclipse 中,单击 “文件”In Eclipse, click File. “文件” 菜单上,单击 “导入”On the File menu, click Import. “导入” 对话框中,选择 “Android/现有 Android 代码到工作区”In the Import dialog box, select Android / Existing Android Code into Workspace.

    将其导入到工作区

  • 单击“下一步”。 Click Next. 导航以选择在其中提取*_adrms android_sdk*的文件夹。Navigate to select the folder in which you extracted the adrms_android_sdk.zip. SDK 应作为 com.microsoft.rightsmanagement 显示在列表中。The SDK should appear in the list as com.microsoft.rightsmanagement.

    导航到“选择文件夹”

  • 单击 “完成” 时,SDK 项目显示为以前创建的应用程序的同级。When you click Finish, the SDK project appears as a sibling of your previously created application.

    该 SDK 项目将显示为应用程序的同级

  • 右键单击 “项目” 图标并查看项目的属性。Right-click the Project icon and view the properties for the project.

  • 导航到 “Android” 选项卡。Navigate to the Android tab.

  • 单击 “添加”,然后从工作区中选择 com.microsoft.rightsmanagement 库。Click Add, and then select the com.microsoft.rightsmanagement library from the workspace.

    添加库

  • 单击“确定”。 Click OK.

    由于 MS RMS SDK 4.2 与 AAD RM 连接,因此应用程序必须被授予INTERNET并**_访问网络_状态**。Because the MS RMS SDK 4.2 connects with AAD RM, the application has to be granted the INTERNET and ACCESS_NETWORK_STATE. 为此,请在项目的根目录中打开 AndroidManifest.xml 文件。To do so, open the AndroidManifest.xml file in the root of the project.

    若要添加权限,请单击 “添加”,然后选择 “使用权限”To add the permissions, click Add, and then select Uses Permissions.

    添加权限

  • 可以通过在文本编辑器视图中查看清单来验证清单步骤。You can verify the manifest step by viewing the manifest in the text editor view. 确保显示以下行:Make sure the following lines appear:

    <uses-sdk
         android:minSdkVersion="15"
         android:targetSdkVersion="19"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission/>
    

请注意  ,SDK 使用的支持 v4Note  The SDK uses the android.support.v4

  • 你现在已准备就绪,可创建新 Android 应用。You are now ready to create your own new Android apps.

另请参阅See Also

入门Get started

新增功能What's new

开发人员术语和概念Developer terms and concepts

Android API 参考Android API Reference