Android.App.Activity.StartActivityForResult Method
Launch an activity for which you would like a result when it finished.

Syntax

[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)

Parameters

intent
The intent to start.
requestCode
If >= 0, this code will be returned in onActivityResult() when the activity exits.
options
Additional options for how the Activity should be started. See Android.Content.Context.StartActivity(Android.Content.Intent, Android.OS.Bundle) for more details.

Exceptions

TypeReason
Android.Content.ActivityNotFoundException

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 Activity.startActivity(android.content.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 Android.Content.Intent.ActionMain or Android.Content.Intent.ActionView), you may not get the result when you expect. For example, if the activity you are launching uses the singleTask launch mode, 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 Android.Content.ActivityNotFoundException if there was no Activity found to run the given Intent.

[Android Documentation]

Requirements

Namespace: Android.App
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 16