Pregunta

I started an temp activity from notifiation, just show some text messages.Whatever I set launchMode=singleInstance or noHistory=true, The temp activity showed last time will show again when enter from "Recent open". I want temp activity to be shown only if I clicked notification, don't show in the "Recent open". Thank you in advance.

    <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);

EDIT: @Lalit Poptani, I tried what you suggest, but it is not waht I need. After I click temp activity with android:excludeFromRecents="true", My app disappeared in "Recent".(user can't find it, my all activity is excluded)

EDIT: Fact: I have 3 tmp activity showing some text just like toast did, 2 were opened from widget and they didn't mixed with app stack. 1 were opend from notification, it always show itself individually from "Recent".

    <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" >

¿Fue útil?

Solución

For removing your Activity from Recent Apps you can use android:excludeFromRecents, so try adding android:excludeFromRecents="true" to your Activity tag.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top