Notes
Android
Android
  • 🤖AOSP
    • Clone AOSP repository
    • Directory Structure
    • Setup IDE
      • Setup VSCode
    • Build
      • BluePrint for Application Project
      • BluePrint for Android Library Project
    • Manifest
      • sharedUserId
      • persistant
  • Gradle
    • Create Custom Build Config Variables
    • Create Custom manifest Variables
    • Make app debugable
  • Android Process
    • Find a process by name
    • Kill a process by Id
  • Catch any exception in Android
  • 🎨Theming
    • Theming
      • RRO
        • RRO Internals
        • RRO classes in AOSP
        • RRO Example
        • RRO Permission
      • Fabricated RRO (FRRO)
        • FRRO Example
        • Permission
  • Lifecycle
    • Basics
      • Lifecycle
        • Activity
        • Fragment
          • Fragment add
    • Lifecycle Aware Custom Class
  • ℹ️Interview
    • Interview Questions
    • Architecture Pattern
      • MVC Architecture pattern
      • MVP Architecture Pattern
      • MVVM Architecture Pattern
  • ↔️AIDL
    • Simple AIDL Communication
      • Creating an AIDL file
      • Create an AIDL server
      • Create AIDL client
      • Limitations
    • AIDL with callback
      • Create AILD interfaces
      • Create an AIDL server
      • Create AIDL client
Powered by GitBook
On this page
  1. AOSP
  2. Manifest

sharedUserId

android:sharedUserId="com.example.shared"

The android:sharedUserId attribute in the Android manifest file is used to share the data, processes, and other resources between two or more applications. By default, each Android application has its own unique user ID. However, if two or more applications share the same user ID, they can access each other's data and run in the same process.

To use android:sharedUserId, you need to set the attribute to the same value for all of the applications that you want to share resources. You also need to make sure that all of the applications are signed with the same certificate.

Here is an example of how to use android:sharedUserId:

Code snippet

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    android:sharedUserId="android.uid.system" >

    <application ... >
        ...
    </application>

</manifest>

In this example, the android:sharedUserId attribute is set to the value com.example.shared. This means that any application that is signed with the same certificate and has the same android:sharedUserId attribute will be able to share resources with this application.

Note: The use of android:sharedUserId is discouraged in newer versions of Android. Instead, you should use other mechanisms, such as services and content providers, to facilitate interoperability between shared components.

Here are some of the benefits of using android:sharedUserId:

  • It can simplify development by allowing you to share code and resources between applications.

  • It can improve performance by allowing applications to run in the same process.

  • It can improve security by allowing you to control access to shared resources.

However, there are also some potential drawbacks to using android:sharedUserId:

  • It can make it more difficult to debug applications.

  • It can increase the risk of security vulnerabilities.

  • It can make it more difficult to update applications.

Overall, the decision of whether or not to use android:sharedUserId depends on your specific needs. If you need to share resources between applications, then android:sharedUserId can be a useful tool. However, you should carefully consider the potential drawbacks before using it.

PreviousManifestNextpersistant

Last updated 1 year ago

🤖