Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

onActivityResult() & onResume() [duplicate]

Tags:

android

Could someone tell me which gets called first, is it onActivityResult() or is it onResume()? Example:

Activity A calls startActivityForResult() to start Activity B. B executes, completes and returns a result to A, but which method of A is called first, onActivityResult() or onResume()?

I know someone has answered this question already by referring to the Activity Docs, however I couldn't find in there myself.

like image 953
D-Dᴙum Avatar asked Jun 24 '11 13:06

D-Dᴙum


People also ask

What is onActivityResult?

onActivityResult is the callback you have on the first activity to grab the contacts you choose. Follow this answer to receive notifications.

What is the use of onActivityResult in Android?

When you done with the subsequent activity and returns, the system calls your activity's onActivityResult() method. This method includes three arguments: @The request code you passed to startActivityForResult() . @A result code specified by the second activity.

What is called after onActivityResult?

you are right, onActivityResult() is getting called before onResume().


1 Answers

First calling onActivityResult() then onResume().

Quote from docs:

protected void onActivityResult (int requestCode, int resultCode, Intent data)

Since: API Level 1 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 resultCode will be RESULT_CANCELED if the activity explicitly returned that, didn't return any result, or crashed during its operation. You will receive this call immediately before onResume() when your activity is re-starting.

like image 91
jamapag Avatar answered Oct 04 '22 17:10

jamapag