android - 如果 Activity 的启动模式为 singleInstance,则不会触发 onActivityResult

标签 android android-activity single-instance

我有一个 Activity,它基本上是我的主要 Activity,它的启动模式是单实例。但是由于 singleInstance,onActivityResult() 回调不会触发。如果我将 list 文件中的启动模式更改为任何其他模式,它就可以正常工作。

你能解释一下为什么这个回调不起作用吗?

最佳答案

我认为问题在于 singleInstance 不允许被调用者 Activity 与调用者存在于同一任务中,因此它无法将值返回给调用者。

考虑使用 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

关于android - 如果 Activity 的启动模式为 singleInstance,则不会触发 onActivityResult,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5118525/

相关文章:

android - 我无法使用方法 dismiss() 停止 ProgressDialog;

android - 在 Android 应用程序中嵌入 Youtube 实时聊天

Android - 当对象不可序列化或不可打包时将对象传递给 Activity

android - 如何创建一个共享首选项的单个实例,它可以在 flutter 的整个项目中使用

Android 将信息传递给 SingleInstance Activity

android - 设备所有者管理员/DevicePolicyManager,可以在 Android 上自动打开移动数据和数据漫游吗?

android - 如何在android中以编程方式录制我的应用程序屏幕的视频

Android 应用程序崩溃, list 问题

android - setFastScrollEnabled 在我的所有手机上都能正常工作,但在 Honeycomb 平板电脑上会崩溃

java - 将单例用于不可变的无参数类不好吗?