Clear backstack in Android pre Honeycomb?

老子叫甜甜 提交于 2019-12-06 12:00:21

You can also use a broadcast listener.

Just make a broadcast listener in all the activities with a "STRING" to recognise.

Whenever you want to delete all the activities, fire the intent.

Those activities that have registered for the above listener (to be done by depending on which activites you wanna finish), will intercept that and will get finish.

This is gonna work in any release of the Android.

Why don't you create a static ArrayList of all the previous activities and clear the ones you don't want whenever you want using the activity.destroy()

you are looking for this:

Intent intent = new Intent(activity, activityClass);
ComponentName cn = intent.getComponent();
Intent mainIntent = IntentCompat.makeRestartActivityTask(cn);
activity.startActivity(mainIntent);

use android compatibillity lib from google - found in the sdk.

depending on your API version it might also be:

Intent mainIntent = IntentCompat.makeMainActivity(cn);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!