两款Android应用程序相同的用户ID [英] Two Android applications with the same user ID

查看:168
本文介绍了两款Android应用程序相同的用户ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

http://developer.android.com/guide/topics/fundamentals.html

这是可能的安排两个应用程序分享相同的Linux   用户ID,在这种情况下,他们能够访问彼此的文件。至   节约系统资源,拥有相同的用户ID的应用程序也可以   安排在同一个Linux进程运行,共享相同的VM(即   应用程序也必须具有相同的证书签名的)。

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为两个应用程序?任何例子吗?

How can we achieve same user ID for two applications? Any example?

推荐答案

您可以通过设置 sharedUserLabel sharedUserId 在AndroidManifest.xml文件中为相同的值。举个例子,如果我有以下2清单文件(我只包括开头):

You can do this by setting the sharedUserLabel and sharedUserId in the AndroidManifest.xml file to the same value. As an example, if I have the following 2 manifest files (I only included the beginning):

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

那么它们都将共享相同的用户。

then they will both share the same user.

这篇关于两款Android应用程序相同的用户ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆