Activity.LaunchedFromPackage Property

Definition

Returns the package name of the app that initially launched this activity.

public virtual string? LaunchedFromPackage { [Android.Runtime.Register("getLaunchedFromPackage", "()Ljava/lang/String;", "GetGetLaunchedFromPackageHandler", ApiSince=34)] get; }
[<get: Android.Runtime.Register("getLaunchedFromPackage", "()Ljava/lang/String;", "GetGetLaunchedFromPackageHandler", ApiSince=34)>]
member this.LaunchedFromPackage : string

Property Value

the package name of the launching app or null if the current activity cannot access the identity of the launching app

Attributes

Remarks

Returns the package name of the app that initially launched this activity. In order to receive the launching app's package name, at least one of the following has to be met: The 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 launching 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 requirement). Starting in Build.VERSION_CODES.CINNAMON_BUN, the activity was launched directly with Activity.startActivityForResult(Intent,int). . These are the same requirements for getLaunchedFromUid(); if any of these are met, then these methods can be used to obtain the uid and package name of the launching app. If none are met, then null is returned. Note, if an activity is launched via startActivityForResult(Intent,int) but the launch is intercepted and forwarded by an intermediate app using Intent.FLAG_ACTIVITY_FORWARD_RESULT, the identity of the intermediate app will not be implicitly shared. In this forwarding scenario, the intermediate app must explicitly opt-in using ActivityOptions.setShareIdentityEnabled(boolean). Prior to Build.VERSION_CODES.CINNAMON_BUN, the launching app's identity was not implicitly shared for any result-based launches and could only be retrieved via getCallingPackage()

See also:

Android reference for android.app.Activity.getLaunchedFromPackage.

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