Share via


ComponentCaller.Uid Property

Definition

Returns the uid of this component caller.

public int Uid { [Android.Runtime.Register("getUid", "()I", "", ApiSince=35)] get; }
[<get: Android.Runtime.Register("getUid", "()I", "", ApiSince=35)>]
member this.Uid : int

Property Value

the uid of the calling app or Process#INVALID_UID if the current component cannot access the identity of the calling app or the caller is invalid

Attributes

Remarks

Returns the uid of this component caller.

<b>Note</b>, in android.os.Build.VERSION_CODES#VANILLA_ICE_CREAM only Activity has access to ComponentCaller instances.

<h3>Requirements for Activity callers</h3>

In order to receive the calling app's uid, at least one of the following has to be met: <ul> <li>The calling app must call ActivityOptions#setShareIdentityEnabled(boolean) with a value of true and launch this activity with the resulting ActivityOptions. <li>The launched activity has the same uid as the calling app. <li>The launched activity is running in a package that is signed with the same key used to sign the platform (typically only system packages such as Settings will meet this requirement). </ul> These are the same requirements for #getPackage(); if any of these are met, then these methods can be used to obtain the uid and package name of the calling app. If none are met, then Process#INVALID_UID is returned.

Note, even if the above conditions are not met, the calling app's identity may still be available from Activity#getCallingPackage() if this activity was started with Activity#startActivityForResult to allow validation of the result's recipient.

Java documentation for android.app.ComponentCaller.getUid().

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to