本文整理匯總了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;
}
示例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");
}
}
示例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;
}
示例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;
}
示例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);
}
示例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();
}
}
示例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();
}
}
示例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;
}