Activity.StartActivityForResult Method

Definition

Overloads

Name Description
StartActivityForResult(Intent, Int32)

Same as calling startActivityForResult(Intent,int,Bundle) with no options.

StartActivityForResult(Type, Int32)

Starts an activity of the specified managed type and requests a result.

StartActivityForResult(Intent, Int32, Bundle)

Launch an activity for which you would like a result when it finished.

StartActivityForResult(Intent, Int32)

Same as calling startActivityForResult(Intent,int,Bundle) with no options.

[Android.Runtime.Register("startActivityForResult", "(Landroid/content/Intent;I)V", "GetStartActivityForResult_Landroid_content_Intent_IHandler")]
public virtual void StartActivityForResult(Android.Content.Intent? intent, int requestCode);
[<Android.Runtime.Register("startActivityForResult", "(Landroid/content/Intent;I)V", "GetStartActivityForResult_Landroid_content_Intent_IHandler")>]
abstract member StartActivityForResult : Android.Content.Intent * int -> unit
override this.StartActivityForResult : Android.Content.Intent * int -> unit

Parameters

intent
Intent

Intent: The intent to start.

requestCode
Int32

int: If >= 0, this code will be returned in onActivityResult() when the activity exits; If < 0, no result will return when the activity exits.

Attributes

Remarks

Same as calling startActivityForResult(Intent,int,Bundle) with no options.

See also:

Throws: android.content.ActivityNotFoundException

Android reference for android.app.Activity.startActivityForResult.

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

StartActivityForResult(Type, Int32)

Starts an activity of the specified managed type and requests a result.

public void StartActivityForResult(Type activityType, int requestCode);
member this.StartActivityForResult : Type * int -> unit

Parameters

activityType
Type

The managed Activity type to start.

requestCode
Int32

If non-negative, the code returned to OnActivityResult when the activity exits; if negative, no result is returned.

Remarks

This managed convenience overload creates an Intent for activityType and starts it for a result.

Android reference for android.app.Activity.startActivityForResult.

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

StartActivityForResult(Intent, Int32, Bundle)

Launch an activity for which you would like a result when it finished.

[Android.Runtime.Register("startActivityForResult", "(Landroid/content/Intent;ILandroid/os/Bundle;)V", "GetStartActivityForResult_Landroid_content_Intent_ILandroid_os_Bundle_Handler")]
public virtual void StartActivityForResult(Android.Content.Intent? intent, int requestCode, Android.OS.Bundle? options);
[<Android.Runtime.Register("startActivityForResult", "(Landroid/content/Intent;ILandroid/os/Bundle;)V", "GetStartActivityForResult_Landroid_content_Intent_ILandroid_os_Bundle_Handler")>]
abstract member StartActivityForResult : Android.Content.Intent * int * Android.OS.Bundle -> unit
override this.StartActivityForResult : Android.Content.Intent * int * Android.OS.Bundle -> unit

Parameters

intent
Intent

Intent: The intent to start.

requestCode
Int32

int: If >= 0, this code will be returned in onActivityResult() when the activity exits; If < 0, no result will return when the activity exits.

options
Bundle

Bundle: Additional options for how the Activity should be started. See android.content.Context.startActivity(Intent,Bundle) Context.startActivity(Intent, Bundle)} for more details. This value may be null.

Attributes

Remarks

Launch an activity for which you would like a result when it finished. When this activity exits, your onActivityResult() method will be called with the given requestCode. Using a negative requestCode is the same as calling startActivity(Intent) (the activity is not launched as a sub-activity). Note that this method should only be used with Intent protocols that are defined to return a result. In other protocols (such as Intent.ACTION_MAIN or Intent.ACTION_VIEW), you may not get the result when you expect. For example, if the activity you are launching uses Intent.FLAG_ACTIVITY_NEW_TASK, it will not run in your task and thus you will immediately receive a cancel result. As a special case, if you call startActivityForResult() with a requestCode >= 0 during the initial onCreate(Bundle savedInstanceState)/onResume() of your activity, then your window will not be displayed until a result is returned back from the started activity. This is to avoid visible flickering when redirecting to another activity. This method throws ActivityNotFoundException if there was no Activity found to run the given Intent.

See also:

Throws: android.content.ActivityNotFoundException

Android reference for android.app.Activity.startActivityForResult.

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