两个具有相同用户ID的Android应用程序

前端之家收集整理的这篇文章主要介绍了两个具有相同用户ID的Android应用程序前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
http://developer.android.com/guide/topics/fundamentals.html

It’s possible to arrange for two applications to share the same Linux
user ID,in which case they are able to access each other’s files. To
conserve system resources,applications with the same user ID can also
arrange to run in the same Linux process and share the same VM (the
applications must also be signed with the same certificate).

我们如何为两个应用程序实现相同的用户ID?任何例子?

解决方法

您可以通过将AndroidManifest.xml文件中的sharedUserLabel和sharedUserId设置为相同的值来实现此目的.例如,如果我有以下2个清单文件(我只包括开始):
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      android:sharedUserLabel="@string/label_shared_user" android:sharedUserId="com.example" package="com.example.package1" android:versionName="2.0.0" android:versionCode="2">

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      android:sharedUserLabel="@string/label_shared_user" android:sharedUserId="com.example" package="com.example.package2" android:versionName="1.0.0" android:versionCode="1">

那么他们将共享同一个用户.

原文链接:https://www.f2er.com/android/313129.html

猜你在找的Android相关文章