简体   繁体   中英

clearing app activity history when home button is clicked

I am creating a notification with pending intent.

Intent intent = new Intent(context, Dialog.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
pIntent = PendingIntent.getActivity(context, 1, intent, 0);

This will open a dialog activity.If i click close this dialog by clicking on home. next time i click on app iconf from recent menu it again opens the dialog activity which i dont want . I want my main app class to be opened always.

How do i do it?

You can set the android:noHistory="true" in your AndroidManifest.xml.

<activity
        android:name="com.example.launcher.MainActivity"
        android:label="@string/app_name"
        android:noHistory="true"
/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM