Two Android applications with the same user ID (Linux user ID)

For the same user id, you have to set sharedUserLabel and sharedUserId in the AndroidManifest.xml file with the same value in different applications.

For an example:

//Application1
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      android:sharedUserLabel="@string/label_shared_user" 
      android:sharedUserId="com.example" 
      package="com.example.package1">
//Application2
<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:sharedUserId
The name of a Linux user ID that will be shared with other apps. By default, Android assigns each app its own unique user ID. However, if this attribute is set to the same value for two or more apps, they will all share the same ID — provided that their certificate sets are identical. Apps with the same user ID can access each other’s data and, if desired, run in the same process.

android:sharedUserLabel
A user-readable label for the shared user ID. The label must be set as a reference to a string resource; it cannot be a raw string.
This attribute was introduced in API Level 3. It is meaningful only if the sharedUserId attribute is also set.

References:
https://stackoverflow.com/questions/9783765/what-is-shareduserid-in-android-and-how-is-it-used/9784342
https://developer.android.com/guide/topics/manifest/manifest-element#uid

Leave a comment