onActivityResult do not fire if launch mode of activity is singleInstance

前端 未结 5 1846
無奈伤痛
無奈伤痛 2020-12-02 20:52

I have an Activity which is basically my main activity and its launch mode is single instance. But because of singleInstance, the onActivityResult() callback do

5条回答
  •  [愿得一人]
    2020-12-02 21:10

    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

提交回复
热议问题