singleTask 启动模式不起作用

瓦伦·夏尔马

即使在将launchMode指定为singleTask之后,我的活动的多个实例也会被创建这个奇怪的问题。有没有人遇到过这个问题?任何指针将不胜感激。

以下是我在清单中声明我的活动的方式:

    <activity
    android:name="com.test.TestActivity"
        android:launchMode="singleTask">
     <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

            <intent-filter>
                <action android:name="android.intent.action.SEND" />
                <action android:name="android.intent.action.SEND_MULTIPLE" />

                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="*/*" />
            </intent-filter>
</activity>

这就是我在仍处于前台时启动我的活动的方式:

Intent sendIntent = new Intent();
        sendIntent.setAction(Intent.ACTION_SEND);
        sendIntent.putExtra(Intent.EXTRA_TEXT, sharedText);
        sendIntent.setType("text/plain");
        activity.startActivity(Intent.createChooser(sendIntent, "Share"));

我正在测试的 Android 版本是 5.1.1

瓦伦·夏尔马

所以似乎问题出在设备上。在模拟器和其他具有相同 android 版本 singleTask 的设备上工作得很好。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章