gpt4 book ai didi

android - 小部件启动应用程序的第二个实例

转载 作者:行者123 更新时间:2023-11-29 14:09:38 26 4
gpt4 key购买 nike

当我的小部件被点击时,我无法从我的小部件启动我的应用程序。这是一些代码的 fragment

// Create an Intent to launch activity
Intent intent = new Intent(context, Entry_MainTabView.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
updateViews.setOnClickPendingIntent(R.id.Widget, pendingIntent);

现在来看这个场景。我启动我的应用程序,退出到主页,然后单击我的小部件。它启动应用程序的第二个实例,所以当我点击“返回”时,应用程序消失并显示另一个副本。然后我再次回击,最后回到主屏幕。

如果 ram 中不存在实例,我如何才能让 Intent 只创建一个新实例?

最佳答案

你看过singleInstance and singleTask launch modes of an activity了吗? ? This extract from Pro Android 2表示没有记录的方法来确保只有一个小部件实例在运行。

关于android - 小部件启动应用程序的第二个实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4356146/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com