Språk

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. On Android 15, only activities have access to ComponentCaller instances. For an activity, the following conditions can allow access to the calling app's identity, subject to platform compatibility rules and a valid caller: the calling app enables identity sharing using ActivityOptions.setShareIdentityEnabled(boolean) and launches the activity with those options; the launched activity has the same UID as the calling app; or the launched activity is in a package signed with the platform key. Other privileged access may also apply. The same access check applies to getUid(). If access is not allowed or the caller is invalid, this property returns null. The calling app's identity may also be available from Activity.getCallingPackage() if the activity was started with Activity.startActivityForResult to allow validation of the result's recipient.

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