Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two Android applications with the same user ID

Tags:

android

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

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

like image 800
SBK Avatar asked Jun 15 '11 06:06

SBK


People also ask

Can you have 2 of the same app on Android?

Using the Native Android Cloning FeatureSome Android devices offer native support for app cloning. It lets you run multiple copies of the same app without having to install any third-party tool. This feature is available on Samsung, Xiaomi, Oppo, and OnePlus phones, among others.

How can two Android applications share the same Linux user ID and the VM?

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


1 Answers

You can do this by setting the sharedUserId and sharedUserLabel 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"
      package="com.example.package1" 
      android:sharedUserId="userId"
      android:sharedUserLabel="@string/label_shared_user" 
      android:versionCode="1" 
      android:versionName="1.0.0">

and

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

then they will both share the same user.

like image 147
Femi Avatar answered Oct 05 '22 18:10

Femi