Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

onActivityResult do not fire if launch mode of activity is singleInstance

I have an Activity which is basically my main activity and its launch mode is single instance. But because of singleInstance, the onActivityResult() callback does not fire. And if I change the launch mode in my manifest file to any other mode it works fine.

Can you explain why this callback is not working?

like image 538
sajjoo Avatar asked Feb 25 '11 14:02

sajjoo


2 Answers

I believe that the problem is that singleInstance doesn't let the callee activity to exist in the same task as the caller, hence it can't return the value to the caller.

Consider using singleTask instead:

singleTask

The system creates the activity at the root of a new task and routes the intent to it. However, if an instance of the activity already exists, the system routes the intent to existing instance through a call to its onNewIntent() method, rather than creating a new one.

singleInstance

Same as "singleTask", except that the system doesn't launch any other activities into the task holding the instance. The activity is always the single and only member of its task.

http://developer.android.com/guide/topics/manifest/activity-element.html

like image 54
Pedro Loureiro Avatar answered Nov 10 '22 07:11

Pedro Loureiro


If an activity is singleInstance, it will be the only one in the task so it always be the top of the task. So when you call startActivityForResult it will fire the callback method immediately.

like image 5
George Avatar answered Nov 10 '22 05:11

George