The role and difference of PID and UID in Android

Source: Internet
Author: User

PID: for Process Identifier, PID is the identity of the processes.

The program run system is automatically assigned to the process a unique PID. After the process aborts the PID is reclaimed by the system, may be continued to assign to the new running program, but in the Android system generally does not have the lost process ID reassigned to the new process, the newly generated process number is generally larger than all the process number before the production.

UID: It is generally understood that user identifier,uid is the ID of the subscriber in Linux.

Indicates which user ran the program, primarily for the administration of permissions. And in Android is different, because Android is a single user system, the UID is given a new mission, data sharing, in order to achieve data sharing, Android for each application almost all assigned a different UID, unlike traditional Linux, Each user has the same UID assigned to it. (This, of course, indicates a problem that Android can only be a single-user system, which was castrated by their engineers at the beginning of the design), making it a tool for data sharing.

So in Android, the PID, and UID are used to identify the identity of the application, but the UID is for different programs to use the shared data.

In Android to share data through the UID can only be configured in the program A, a, menifest configuration, as follows:

<manifest xmlns:android= "Http://schemas.android.com/apk/res/android"
Package= "com.perseus.a"
Android:versioncode= "1"
Android:versionname= "1.0"
Android:shareduserid= "Com.share"
>
<manifest xmlns:android= "Http://schemas.android.com/apk/res/android"
Package= "com.perseus.b"
Android:versioncode= "1"
Android:versionname= "1.0"
Android:shareduserid= "Com.share"
>

This allows us to access the data in B by jumping activity in the a program.

In this case you may have doubts, if let other development this know our shareuserid know our ID, then our data is not exposed, rest assured that Google will not make such a low-level error, we want to make different programs can access each other, but also need to have the same signature, Each company or developer's signature is unique, so we don't have to worry about it, the other two can access, don't forget the permissions.

The role and difference of PID and UID in Android

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.