Aracılığıyla paylaş


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: <ul> <li>The 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 launching 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 #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, even if the above conditions are not met, the launching app's identity may still be available from #getCallingPackage() if this activity was started with Activity#startActivityForResult to allow validation of the result's recipient.

Java documentation 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