首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Android LaunchMode不工作

Android LaunchMode不工作
EN

Stack Overflow用户
提问于 2012-10-23 15:38:39
回答 1查看 1K关注 0票数 1

我启动了一个临时活动从通知,只是显示一些文本messages.Whatever我设置了launchMode=singleInstance或noHistory=true,上次显示的临时活动将再次显示从“最近打开”。我希望只有当我点击通知时才显示临时活动,而不是显示在“最近打开”中。提前谢谢你。

代码语言:javascript
复制
    <activity
        android:name=".NotifiticationDialog"
        android:launchMode="singleInstance"
        android:noHistory="true"
        android:theme="@android:style/Theme.Translucent.NoTitleBar" >


            Notification notification = new Notification(R.drawable.icon, context.getString(R.string.app_name), System.currentTimeMillis());
            Intent intent = new Intent(context, NotifiticationDialog.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
            PendingIntent activity = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
            notifycation.setLatestEventInfo(context, context.getString(R.string.app_name), message, activity);
            notifycation.flags = Notification.FLAG_AUTO_CANCEL;
            _nm.notify(NotifiticationDialog.ID, text);

编辑:@Lalit Poptani,我尝试了你的建议,但这不是我需要的。在我用android:excludeFromRecents="true“点击临时活动后,我的应用程序在”最近“中消失了。(用户找不到它,我的所有活动都被排除在外)

编辑:事实:我有3个tmp活动显示一些文本,就像toast一样,2个是从窗口小部件打开的,它们没有与应用程序堆栈混合。1是从通知中打开的,它总是从“最近”中单独显示。

代码语言:javascript
复制
    <activity
        android:name=".AppwidgetDialog1"
        android:launchMode="singleInstance"
        android:noHistory="true"
        android:theme="@android:style/Theme.Translucent.NoTitleBar" />
    <activity
        android:name=".AppwidgetDialog2"
        android:launchMode="singleInstance"
        android:noHistory="true"
        android:theme="@android:style/Theme.Translucent.NoTitleBar" />
    <activity
        android:name=".NotifiticationDialog"
        android:excludeFromRecents="true"
        android:theme="@android:style/Theme.Translucent.NoTitleBar" >
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-10-23 15:41:37

为了从最近的应用程序中删除你的活动,你可以使用android:excludeFromRecents,所以尝试将android:excludeFromRecents="true"添加到你的活动标签中。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13025617

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档