Skip to content Skip to sidebar Skip to footer

Android: Startactivityforresult Not Calling Onactivityresult

My Setup A Service running in its own process, CentralService An activity that calls startActivityForResult(), MainActivity The activity that is being started for result, ReturnR

Solution 1:

After coming back to this question 2 years later the issue is because the activity is launched in a new task. (I set this in the intent I fire). Starting an activity for result that launches in a new task immediately will return -1.

Solution 2:

After you call

startActivityForResult(listenIntent, 500);

In the com.custom.returnresultaction class, are you including this code?

setResult(RESULT_CANCELED, i);

or setResult(RESULT_OK, i);

and call finish();

You need to set the result and call finish().

Post a Comment for "Android: Startactivityforresult Not Calling Onactivityresult"