Language

LocalActivityManager.StartActivity(String, Intent) Method

Definition

Caution

deprecated

Start a new activity running in the group.

[Android.Runtime.Register("startActivity", "(Ljava/lang/String;Landroid/content/Intent;)Landroid/view/Window;", "GetStartActivity_Ljava_lang_String_Landroid_content_Intent_Handler")]
[System.Obsolete("deprecated")]
public virtual Android.Views.Window? StartActivity(string? id, Android.Content.Intent? intent);
[<Android.Runtime.Register("startActivity", "(Ljava/lang/String;Landroid/content/Intent;)Landroid/view/Window;", "GetStartActivity_Ljava_lang_String_Landroid_content_Intent_Handler")>]
[<System.Obsolete("deprecated")>]
abstract member StartActivity : string * Android.Content.Intent -> Android.Views.Window
override this.StartActivity : string * Android.Content.Intent -> Android.Views.Window

Parameters

id
String

Unique identifier of the activity to be started

intent
Intent

The Intent describing the activity to be started

Returns

Returns the window of the activity. The caller needs to take care of adding this window to a view hierarchy, and likewise dealing with removing the old window if the activity has changed.

Attributes

Exceptions

Remarks

Start a new activity running in the group. Every activity you start must have a unique string ID associated with it. If you call StartActivity(String, Intent) again with the same ID, the current activity may be reused or destroyed and replaced, based on these conditions, in order:

  • If the Intent maps to a different activity component than is currently running, the current activity is finished and a new one started.:
  • If the current activity uses a non-multiple launch mode (such as singleTop), or the Intent has the SingleTop flag set, then the current activity will remain running and its OnNewIntent(Intent) method is called.:
  • If the new Intent is the same (excluding extras) as the previous one, and the new Intent does not have ClearTop set, then the current activity will remain running as-is.:
  • Otherwise, the current activity will be finished and a new one started.:

If the given Intent can not be resolved to an available Activity, this method throws ActivityNotFoundException. Warning: There is an issue where, if the Intent does not include an explicit component, we can restore the state for a different activity class than was previously running when the state was saved (if the set of available activities changes between those points).

Android reference for android.app.LocalActivityManager.startActivity.

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