Activity.OnActivityResult Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
OnActivityResult(Int32, Result, Intent) |
Called when an activity you launched exits, giving you the requestCode you started it with, the resultCode it returned, and any additional data from it. |
OnActivityResult(Int32, Result, Intent, ComponentCaller) |
Same as |
OnActivityResult(Int32, Result, Intent)
Called when an activity you launched exits, giving you the requestCode you started it with, the resultCode it returned, and any additional data from it.
[Android.Runtime.Register("onActivityResult", "(IILandroid/content/Intent;)V", "GetOnActivityResult_IILandroid_content_Intent_Handler")]
protected virtual void OnActivityResult (int requestCode, Android.App.Result resultCode, Android.Content.Intent? data);
[<Android.Runtime.Register("onActivityResult", "(IILandroid/content/Intent;)V", "GetOnActivityResult_IILandroid_content_Intent_Handler")>]
abstract member OnActivityResult : int * Android.App.Result * Android.Content.Intent -> unit
override this.OnActivityResult : int * Android.App.Result * Android.Content.Intent -> unit
Parameters
- requestCode
- Int32
The integer request code originally supplied to startActivityForResult(), allowing you to identify who this result came from.
- resultCode
- Result
The integer result code returned by the child activity through its setResult().
- data
- Intent
An Intent, which can return result data to the caller (various data can be attached to Intent "extras").
- Attributes
Remarks
Called when an activity you launched exits, giving you the requestCode you started it with, the resultCode it returned, and any additional data from it. The <var>resultCode</var> will be #RESULT_CANCELED
if the activity explicitly returned that, didn't return any result, or crashed during its operation.
An activity can never receive a result in the resumed state. You can count on #onResume
being called after this method, though not necessarily immediately after. If the activity was resumed, it will be paused and the result will be delivered, followed by #onResume
. If the activity wasn't in the resumed state, then the result will be delivered, with #onResume
called sometime later when the activity becomes active again.
This method is never invoked if your activity sets android.R.styleable#AndroidManifestActivity_noHistory noHistory
to true
.
Java documentation for android.app.Activity.onActivityResult(int, int, android.content.Intent)
.
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.
See also
- <xref:Android.App.Activity.StartActivityForResult(Android.Content.Intent%2c+System.Int32)>
- <xref:Android.App.Activity.CreatePendingResult(System.Int32%2c+Android.Content.Intent%2c+Android.Content.Intent)>
- SetResult(Result)
Applies to
OnActivityResult(Int32, Result, Intent, ComponentCaller)
Same as #onActivityResult(int, int, Intent)
, but with an extra parameter for the
ComponentCaller instance associated with the app that sent the result.
[Android.Runtime.Register("onActivityResult", "(IILandroid/content/Intent;Landroid/app/ComponentCaller;)V", "GetOnActivityResult_IILandroid_content_Intent_Landroid_app_ComponentCaller_Handler", ApiSince=35)]
public virtual void OnActivityResult (int requestCode, Android.App.Result resultCode, Android.Content.Intent? data, Android.App.ComponentCaller caller);
[<Android.Runtime.Register("onActivityResult", "(IILandroid/content/Intent;Landroid/app/ComponentCaller;)V", "GetOnActivityResult_IILandroid_content_Intent_Landroid_app_ComponentCaller_Handler", ApiSince=35)>]
abstract member OnActivityResult : int * Android.App.Result * Android.Content.Intent * Android.App.ComponentCaller -> unit
override this.OnActivityResult : int * Android.App.Result * Android.Content.Intent * Android.App.ComponentCaller -> unit
Parameters
- requestCode
- Int32
The integer request code originally supplied to startActivityForResult(), allowing you to identify who this result came from.
- resultCode
- Result
The integer result code returned by the child activity through its setResult().
- data
- Intent
An Intent, which can return result data to the caller (various data can be attached to Intent "extras").
- caller
- ComponentCaller
The ComponentCaller
instance associated with the app that sent the
intent.
- Attributes
Remarks
Same as #onActivityResult(int, int, Intent)
, but with an extra parameter for the ComponentCaller instance associated with the app that sent the result.
If you want to retrieve the caller without overriding this method, call #getCurrentCaller
inside your existing #onActivityResult(int, int, Intent)
.
Note that you should only override one #onActivityResult
method.
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.