Share via


CrossProfileApps.StartMainActivity Method

Definition

Overloads

StartMainActivity(ComponentName, UserHandle)

Starts the specified main activity of the caller package in the specified profile.

StartMainActivity(ComponentName, UserHandle, Activity, Bundle)

Starts the specified main activity of the caller package in the specified profile, launching in the specified activity.

StartMainActivity(ComponentName, UserHandle)

Starts the specified main activity of the caller package in the specified profile.

[Android.Runtime.Register("startMainActivity", "(Landroid/content/ComponentName;Landroid/os/UserHandle;)V", "GetStartMainActivity_Landroid_content_ComponentName_Landroid_os_UserHandle_Handler", ApiSince=28)]
public virtual void StartMainActivity (Android.Content.ComponentName component, Android.OS.UserHandle targetUser);
[<Android.Runtime.Register("startMainActivity", "(Landroid/content/ComponentName;Landroid/os/UserHandle;)V", "GetStartMainActivity_Landroid_content_ComponentName_Landroid_os_UserHandle_Handler", ApiSince=28)>]
abstract member StartMainActivity : Android.Content.ComponentName * Android.OS.UserHandle -> unit
override this.StartMainActivity : Android.Content.ComponentName * Android.OS.UserHandle -> unit

Parameters

component
ComponentName

The ComponentName of the activity to launch, it must be exported and has action android.content.Intent#ACTION_MAIN, category android.content.Intent#CATEGORY_LAUNCHER. Otherwise, SecurityException will be thrown.

targetUser
UserHandle

The UserHandle of the profile, must be one of the users returned by #getTargetUserProfiles(), otherwise a SecurityException will be thrown.

Attributes

Remarks

Starts the specified main activity of the caller package in the specified profile.

Java documentation for android.content.pm.CrossProfileApps.startMainActivity(android.content.ComponentName, android.os.UserHandle).

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

StartMainActivity(ComponentName, UserHandle, Activity, Bundle)

Starts the specified main activity of the caller package in the specified profile, launching in the specified activity.

[Android.Runtime.Register("startMainActivity", "(Landroid/content/ComponentName;Landroid/os/UserHandle;Landroid/app/Activity;Landroid/os/Bundle;)V", "GetStartMainActivity_Landroid_content_ComponentName_Landroid_os_UserHandle_Landroid_app_Activity_Landroid_os_Bundle_Handler", ApiSince=33)]
public virtual void StartMainActivity (Android.Content.ComponentName component, Android.OS.UserHandle targetUser, Android.App.Activity? callingActivity, Android.OS.Bundle? options);
[<Android.Runtime.Register("startMainActivity", "(Landroid/content/ComponentName;Landroid/os/UserHandle;Landroid/app/Activity;Landroid/os/Bundle;)V", "GetStartMainActivity_Landroid_content_ComponentName_Landroid_os_UserHandle_Landroid_app_Activity_Landroid_os_Bundle_Handler", ApiSince=33)>]
abstract member StartMainActivity : Android.Content.ComponentName * Android.OS.UserHandle * Android.App.Activity * Android.OS.Bundle -> unit
override this.StartMainActivity : Android.Content.ComponentName * Android.OS.UserHandle * Android.App.Activity * Android.OS.Bundle -> unit

Parameters

component
ComponentName

The ComponentName of the activity to launch, it must be exported and has action android.content.Intent#ACTION_MAIN, category android.content.Intent#CATEGORY_LAUNCHER. Otherwise, SecurityException will be thrown.

targetUser
UserHandle

The UserHandle of the profile, must be one of the users returned by #getTargetUserProfiles(), otherwise a SecurityException will be thrown.

callingActivity
Activity

The activity to start the new activity from for the purposes of deciding which task the new activity should belong to. If null, the activity will always be started in a new task.

options
Bundle

The activity options or null. See android.app.ActivityOptions.

Attributes

Remarks

Starts the specified main activity of the caller package in the specified profile, launching in the specified activity.

Java documentation for android.content.pm.CrossProfileApps.startMainActivity(android.content.ComponentName, android.os.UserHandle, android.app.Activity, android.os.Bundle).

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