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


Java IntentCompat.makeRestartActivityTask方法代碼示例

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


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

示例1: addShowScenarioShortcut

import android.support.v4.content.IntentCompat; //導入方法依賴的package包/類
public static Intent addShowScenarioShortcut(Context context, Choice choice) {
    Intent addShowScenarioShortcutIntent = new Intent(context, AddShowScenarioShortcutActivity.class);
    addShowScenarioShortcutIntent = IntentCompat.makeRestartActivityTask(addShowScenarioShortcutIntent.getComponent());
    addShowScenarioShortcutIntent.setAction(Intent.ACTION_VIEW);
    addShowScenarioShortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    Serializer serializer = new Persister();
    ByteArrayOutputStream choiceOutputStream = new ByteArrayOutputStream();
    try {
        serializer.write(choice, choiceOutputStream);
    } catch (Exception e) {
        Log.d(TAG, e.toString());
    }
    String choiceXml = choiceOutputStream.toString();
    addShowScenarioShortcutIntent.putExtra(EXTRA_CHOICE_XML, choiceXml);
    return addShowScenarioShortcutIntent;
}
 
開發者ID:nicholasrout,項目名稱:shortstories,代碼行數:17,代碼來源:IntentUtil.java

示例2: doRestart

import android.support.v4.content.IntentCompat; //導入方法依賴的package包/類
public static void doRestart(@NonNull Context cxt) {
    try {
        PackageManager pm = cxt.getPackageManager();
        if (pm != null) {
            Intent intent = pm.getLaunchIntentForPackage(cxt.getPackageName());
            if (intent != null) {
                ComponentName componentName = intent.getComponent();
                Intent mainIntent = IntentCompat.makeRestartActivityTask(componentName);
                mainIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
                        | Intent.FLAG_ACTIVITY_NEW_TASK
                        | Intent.FLAG_ACTIVITY_CLEAR_TASK);
                cxt.startActivity(mainIntent);

                Runtime.getRuntime().exit(0);
            } else {
                LogHelper.d(TAG, "Was not able to restart application, intent null");
            }
        } else {
            LogHelper.d(TAG, "Was not able to restart application, PM null");
        }
    } catch (Exception e) {
        LogHelper.e(TAG, e, "Was not able to restart application");
    }
}
 
開發者ID:avluis,項目名稱:Hentoid,代碼行數:25,代碼來源:Helper.java

示例3: scenarioDialog

import android.support.v4.content.IntentCompat; //導入方法依賴的package包/類
public static Intent scenarioDialog(Context context, String scenario, boolean hasAchievements, boolean isFinish) {
    Intent scenarioDialogIntent = new Intent(context, ScenarioDialogActivity.class);
    scenarioDialogIntent = IntentCompat.makeRestartActivityTask(scenarioDialogIntent.getComponent());
    scenarioDialogIntent.putExtra(EXTRA_SCENARIO, scenario);
    scenarioDialogIntent.putExtra(EXTRA_HAS_ACHIEVEMENTS, hasAchievements);
    scenarioDialogIntent.putExtra(EXTRA_IS_FINISH, isFinish);
    return scenarioDialogIntent;
}
 
開發者ID:nicholasrout,項目名稱:shortstories,代碼行數:9,代碼來源:IntentUtil.java

示例4: quitStory

import android.support.v4.content.IntentCompat; //導入方法依賴的package包/類
public static Intent quitStory(Context context) {
    Intent quitStoryIntent = new Intent(context, QuitStoryActivity.class);
    quitStoryIntent = IntentCompat.makeRestartActivityTask(quitStoryIntent.getComponent());
    quitStoryIntent.setAction(Intent.ACTION_VIEW);
    quitStoryIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    return quitStoryIntent;
}
 
開發者ID:nicholasrout,項目名稱:shortstories,代碼行數:8,代碼來源:IntentUtil.java

示例5: restartApp

import android.support.v4.content.IntentCompat; //導入方法依賴的package包/類
/**
 * Context using {@code contextor}
 **/
public static void restartApp() {
  Context context = ContextProvider.get();
  Intent intent = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
  intent = IntentCompat.makeRestartActivityTask(intent.getComponent());
  intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
  context.startActivity(intent);
}
 
開發者ID:esafirm,項目名稱:androidcommon,代碼行數:11,代碼來源:AndroidUtils.java

示例6: restartActivity

import android.support.v4.content.IntentCompat; //導入方法依賴的package包/類
private void restartActivity() {
    ComponentName componentName;
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.CUPCAKE) {
        componentName = getPackageManager().getLaunchIntentForPackage("com.zlab.noizer.app").getComponent();
        Intent intent = IntentCompat.makeRestartActivityTask(componentName);
        stopAllSound();
        startActivity(intent);
        this.finish();
    }
}
 
開發者ID:ZorgeR,項目名稱:Noizer,代碼行數:11,代碼來源:MainActivity.java

示例7: openIntentWithClear

import android.support.v4.content.IntentCompat; //導入方法依賴的package包/類
public void openIntentWithClear(Intent intent) {
    ComponentName cn = intent.getComponent();
    Intent mainIntent = IntentCompat.makeRestartActivityTask(cn);
    mContext.startActivity(mainIntent);
    try {
        ((Activity) mContext).finish();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:alashow,項目名稱:datmusic-android,代碼行數:11,代碼來源:IntentManager.java

示例8: achievementsDialog

import android.support.v4.content.IntentCompat; //導入方法依賴的package包/類
public static Intent achievementsDialog(Context context) {
    Intent achievementsDialogIntent = new Intent(context, AchievementsDialogActivity.class);
    achievementsDialogIntent = IntentCompat.makeRestartActivityTask(achievementsDialogIntent.getComponent());
    return achievementsDialogIntent;
}
 
開發者ID:nicholasrout,項目名稱:shortstories,代碼行數:6,代碼來源:IntentUtil.java


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