ComponentCaller.Package Property

Definition

Returns the package name of this component caller.

public string? Package { [Android.Runtime.Register("getPackage", "()Ljava/lang/String;", "", ApiSince=35)] get; }
[<get: Android.Runtime.Register("getPackage", "()Ljava/lang/String;", "", ApiSince=35)>]
member this.Package : string

Property Value

the package name of the calling app or null if the current component cannot access the identity of the calling app or the caller is invalid

Attributes

Remarks

Returns the package name of this component caller. Note, in Build.VERSION_CODES.VANILLA_ICE_CREAM only Activity has access to ComponentCaller instances. Requirements for Activity callers In order to receive the calling app's package name, at least one of the following has to be met: The calling app must call ActivityOptions.setShareIdentityEnabled(boolean) with a value of true and launch this activity with the resulting ActivityOptions. The launched activity has the same uid as the calling app. 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 meet this requirement). These are the same requirements for getUid(); 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 null 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.

See also:

Android reference for android.app.ComponentCaller.getPackage.

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