Java Code Examples for android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP
The following are Jave code examples for showing how to use
FLAG_ACTIVITY_SINGLE_TOP of the
android.content.Intent
class.
You can vote up the examples you like. Your votes will be used in our system to get
more good examples.
+ Save this method
Example 1
Project: atlas File: ActivityBridge.java View Source Code | 7 votes |
public static void handleActivityStack(ActivityInfo info, Intent intent) { // Handle launchMode with singleTop, and flag with FLAG_ACTIVITY_SINGLE_TOP int launchMode = info.launchMode; int flag = intent.getFlags(); String launchActivityName = info.name; String prevActivityName = null; List<WeakReference<Activity>> activityList = ActivityTaskMgr.getInstance().getActivityList(); if (activityList.size() > 0) { Activity lastActivity = activityList.get(activityList.size() - 1).get(); prevActivityName = lastActivity.getClass().getName(); } if (StringUtils.equals(prevActivityName, launchActivityName) && (launchMode == ActivityInfo.LAUNCH_SINGLE_TOP || (flag & Intent.FLAG_ACTIVITY_SINGLE_TOP) == Intent.FLAG_ACTIVITY_SINGLE_TOP)) { intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); } else if (launchMode == ActivityInfo.LAUNCH_SINGLE_TASK || launchMode == ActivityInfo.LAUNCH_SINGLE_INSTANCE || (flag & Intent.FLAG_ACTIVITY_CLEAR_TOP) == Intent.FLAG_ACTIVITY_CLEAR_TOP) { int i; boolean isExist = false; for (i = 0; i < activityList.size(); i++) { WeakReference<Activity> ref = activityList.get(i); if (ref!=null && ref.get()!=null && ref.get().getClass().getName().equals(launchActivityName)) { isExist = true; break; } } if (isExist) { for (WeakReference<Activity> act : activityList.subList(i + 1, activityList.size())) { if(act!=null && act.get()!=null) { act.get().finish(); } } activityList.subList(i + 1, activityList.size()).clear(); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); } } }
Example 2
Project: Meepo File: ActivityRouter.java View Source Code | 5 votes |
@TargetClass(BActivity.class) @TargetFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP) void gotoB(Context context, @Bundle("title") String title);