當前位置: 首頁>>代碼示例>>Java>>正文


Java ActivityInfo.LAUNCH_SINGLE_TASK屬性代碼示例

本文整理匯總了Java中android.content.pm.ActivityInfo.LAUNCH_SINGLE_TASK屬性的典型用法代碼示例。如果您正苦於以下問題:Java ActivityInfo.LAUNCH_SINGLE_TASK屬性的具體用法?Java ActivityInfo.LAUNCH_SINGLE_TASK怎麽用?Java ActivityInfo.LAUNCH_SINGLE_TASK使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.content.pm.ActivityInfo的用法示例。


在下文中一共展示了ActivityInfo.LAUNCH_SINGLE_TASK屬性的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: handleActivityStack

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);
        }
    }
}
 
開發者ID:alibaba,項目名稱:atlas,代碼行數:39,代碼來源:ActivityBridge.java

示例2: onActivtyDestory

public static void onActivtyDestory(Activity activity) {
    synchronized (mRunningActivityList) {
        RunningActivityRecord value = mRunningActivityList.remove(activity);
        if (value != null) {
            ActivityInfo targetActivityInfo = value.targetActivityInfo;
            if (targetActivityInfo.launchMode == ActivityInfo.LAUNCH_MULTIPLE) {
                mRunningSingleStandardActivityList.remove(value.index);
            } else if (targetActivityInfo.launchMode == ActivityInfo.LAUNCH_SINGLE_TOP) {
                mRunningSingleTopActivityList.remove(value.index);
            } else if (targetActivityInfo.launchMode == ActivityInfo.LAUNCH_SINGLE_TASK) {
                mRunningSingleTaskActivityList.remove(value.index);
            } else if (targetActivityInfo.launchMode == ActivityInfo.LAUNCH_SINGLE_INSTANCE) {
                mRunningSingleInstanceActivityList.remove(value.index);
            }
        }
    }
}
 
開發者ID:amikey,項目名稱:DroidPlugin,代碼行數:17,代碼來源:RunningActivities.java

示例3: modify

public static Intent modify(Activity target, Intent intent) {
    if (!intent.hasExtra(ApkConstant.EXTRA_APK_PATH)
            && target.getIntent().hasExtra(ApkConstant.EXTRA_APK_PATH)) {
        Bundle extras = intent.getExtras();
        if (extras != null) {
            intent.replaceExtras(new Bundle());
            String extras_id = ApkExtras.putExtras(extras);
            intent.putExtra(ApkConstant.EXTRA_APK_EXTRAS, extras_id);
        }
        String apkPath = target.getIntent().getStringExtra(ApkConstant.EXTRA_APK_PATH);
        intent.putExtra(ApkConstant.EXTRA_APK_PATH, apkPath);
        // launch mode
        if (intent.getComponent() != null) {
            try {
                ActivityInfo activityInfo = ApkLoaded.get(target, apkPath).getActivityInfo(intent.getComponent().getClassName());
                String launchModeStr = HookActivity_Component.STANDARD;
                int launchMode = activityInfo.launchMode;
                if (launchMode == ActivityInfo.LAUNCH_SINGLE_INSTANCE) {
                    launchModeStr = HookActivity_Component.SINGLE_INSTANCE;
                } else if (launchMode == ActivityInfo.LAUNCH_SINGLE_TASK) {
                    launchModeStr = HookActivity_Component.SINGLE_TASK;
                } else if (launchMode == ActivityInfo.LAUNCH_SINGLE_TOP) {
                    launchModeStr = HookActivity_Component.SINGLE_TOP;
                }
                intent.putExtra(ApkConstant.EXTRA_APK_LAUNCH_MODE, launchModeStr);
            } catch (Exception e) {
            }
        }
    }
    return HookActivity_Component.modify(intent);
}
 
開發者ID:LiangMaYong,項目名稱:android-apkbox,代碼行數:31,代碼來源:HookActivity_Intent.java

示例4: getLaunchModeInfix

/**
 * 獲取 launchMode 對應的前綴
 */
private static String getLaunchModeInfix(int launchMode) {
    switch (launchMode) {
        case ActivityInfo.LAUNCH_SINGLE_TOP:
            return "STP";
        case ActivityInfo.LAUNCH_SINGLE_TASK:
            return "ST";
        case ActivityInfo.LAUNCH_SINGLE_INSTANCE:
            return "SI";
        default:
            return "NR";
    }
}
 
開發者ID:wangyupeng1-iri,項目名稱:springreplugin,代碼行數:15,代碼來源:LaunchModeStates.java

示例5: onActivtyCreate

public static void onActivtyCreate(Activity activity, ActivityInfo targetActivityInfo, ActivityInfo stubActivityInfo) {
    synchronized (mRunningActivityList) {
        RunningActivityRecord value = new RunningActivityRecord(activity, targetActivityInfo, stubActivityInfo, findMaxIndex() + 1);
        mRunningActivityList.put(activity, value);
        if (targetActivityInfo.launchMode == ActivityInfo.LAUNCH_MULTIPLE) {
            mRunningSingleStandardActivityList.put(value.index, value);
        } else if (targetActivityInfo.launchMode == ActivityInfo.LAUNCH_SINGLE_TOP) {
            mRunningSingleTopActivityList.put(value.index, value);
        } else if (targetActivityInfo.launchMode == ActivityInfo.LAUNCH_SINGLE_TASK) {
            mRunningSingleTaskActivityList.put(value.index, value);
        } else if (targetActivityInfo.launchMode == ActivityInfo.LAUNCH_SINGLE_INSTANCE) {
            mRunningSingleInstanceActivityList.put(value.index, value);
        }
    }
}
 
開發者ID:amikey,項目名稱:DroidPlugin,代碼行數:15,代碼來源:RunningActivities.java

示例6: beforeStartActivity

public static void beforeStartActivity() {
    synchronized (mRunningActivityList) {
        for (RunningActivityRecord record : mRunningActivityList.values()) {
            if (record.stubActivityInfo.launchMode == ActivityInfo.LAUNCH_MULTIPLE) {
                continue;
            } else if (record.stubActivityInfo.launchMode == ActivityInfo.LAUNCH_SINGLE_TOP) {
                doFinshIt(mRunningSingleTopActivityList);
            } else if (record.stubActivityInfo.launchMode == ActivityInfo.LAUNCH_SINGLE_TASK) {
                doFinshIt(mRunningSingleTopActivityList);
            } else if (record.stubActivityInfo.launchMode == ActivityInfo.LAUNCH_SINGLE_INSTANCE) {
                doFinshIt(mRunningSingleTopActivityList);
            }
        }
    }
}
 
開發者ID:amikey,項目名稱:DroidPlugin,代碼行數:15,代碼來源:RunningActivities.java


注:本文中的android.content.pm.ActivityInfo.LAUNCH_SINGLE_TASK屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。