共用方式為


CrossProfileApps.CanRequestInteractAcrossProfiles Method

Definition

Returns whether the calling package can request to navigate the user to the relevant settings page to request user consent to interact across profiles.

[Android.Runtime.Register("canRequestInteractAcrossProfiles", "()Z", "GetCanRequestInteractAcrossProfilesHandler", ApiSince=30)]
public virtual bool CanRequestInteractAcrossProfiles ();
[<Android.Runtime.Register("canRequestInteractAcrossProfiles", "()Z", "GetCanRequestInteractAcrossProfilesHandler", ApiSince=30)>]
abstract member CanRequestInteractAcrossProfiles : unit -> bool
override this.CanRequestInteractAcrossProfiles : unit -> bool

Returns

true if the calling package can request to interact across profiles.

Attributes

Remarks

Returns whether the calling package can request to navigate the user to the relevant settings page to request user consent to interact across profiles.

If true, the navigation intent can be obtained via #createRequestInteractAcrossProfilesIntent(). The package can then listen to #ACTION_CAN_INTERACT_ACROSS_PROFILES_CHANGED broadcasts.

Specifically, returns whether the following are all true: <ul> <li>UserManager#getEnabledProfileIds(int) returns at least one other profile for the calling user.</li> <li>The calling app has requested android.Manifest.permission.INTERACT_ACROSS_PROFILES in its manifest.</li> <li>The calling app is not a profile owner within the profile group of the calling user.</li> </ul>

Note that in order for the user to be able to grant the consent, the requesting package must be allowlisted by the admin or the OEM and installed in the other profile. If this is not the case the user will be shown a message explaining why they can't grant the consent.

Note that user consent could already be granted if given a return value of true. The package's current ability to interact across profiles can be checked with #canInteractAcrossProfiles().

Java documentation for android.content.pm.CrossProfileApps.canRequestInteractAcrossProfiles().

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