本文整理了Java中android.content.Intent.makeRestartActivityTask()
方法的一些代码示例,展示了Intent.makeRestartActivityTask()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Intent.makeRestartActivityTask()
方法的具体详情如下:
包路径:android.content.Intent
类名称:Intent
方法名:makeRestartActivityTask
暂无
代码示例来源:origin: kingargyle/adt-leanback-support
public static Intent makeRestartActivityTask(ComponentName mainActivity) {
return Intent.makeRestartActivityTask(mainActivity);
}
}
代码示例来源:origin: lianghuiyong/AndroidBase
public void nextActivity(Class<?> firstCls, Class<?> SecondCls) {
Intent[] intents = new Intent[2];
intents[0] = Intent.makeRestartActivityTask(new ComponentName(this, SecondCls));
intents[1] = new Intent(this, firstCls);
startActivities(intents);
}
代码示例来源:origin: li2/learning-android-open-source
/**
* This creates an array of Intent objects representing the back stack
* for a user going into the Views/Lists API demos.
*/
private Intent[] buildIntentsToViewsLists() {
// We are going to rebuild our task with a new back stack. This will
// be done by launching an array of Intents, representing the new
// back stack to be created, with the first entry holding the root
// and requesting to reset the back stack.
Intent[] intents = new Intent[3];
// First: root activity of ApiDemos.
// This is a convenient way to make the proper Intent to launch and
// reset an application's task.
intents[0] = Intent.makeRestartActivityTask(new ComponentName(this,
com.example.android.apis.ApiDemos.class));
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setClass(IntentActivityFlags.this, com.example.android.apis.ApiDemos.class);
intent.putExtra("com.example.android.apis.Path", "Views");
intents[1] = intent;
intent = new Intent(Intent.ACTION_MAIN);
intent.setClass(IntentActivityFlags.this, com.example.android.apis.ApiDemos.class);
intent.putExtra("com.example.android.apis.Path", "Views/Lists");
intents[2] = intent;
return intents;
}
代码示例来源:origin: qiubiteme/android_api_demos
intents[0] = Intent.makeRestartActivityTask(new ComponentName(context,
com.example.android.apis.ApiDemos.class));
代码示例来源:origin: li2/learning-android-open-source
/**
* This method creates an array of Intent objects representing the
* activity stack for the incoming message details state that the
* application should be in when launching it from a notification.
*/
static Intent[] makeMessageIntentStack(Context context, CharSequence from,
CharSequence msg) {
// A typical convention for notifications is to launch the user deeply
// into an application representing the data in the notification; to
// accomplish this, we can build an array of intents to insert the back
// stack stack history above the item being displayed.
Intent[] intents = new Intent[4];
// First: root activity of ApiDemos.
// This is a convenient way to make the proper Intent to launch and
// reset an application's task.
intents[0] = Intent.makeRestartActivityTask(new ComponentName(context,
com.example.android.apis.ApiDemos.class));
// "App"
intents[1] = new Intent(context, com.example.android.apis.ApiDemos.class);
intents[1].putExtra("com.example.android.apis.Path", "App");
// "App/Notification"
intents[2] = new Intent(context, com.example.android.apis.ApiDemos.class);
intents[2].putExtra("com.example.android.apis.Path", "App/Notification");
// Now the activity to display to the user. Also fill in the data it
// should display.
intents[3] = new Intent(context, IncomingMessageView.class);
intents[3].putExtra(IncomingMessageView.KEY_FROM, from);
intents[3].putExtra(IncomingMessageView.KEY_MESSAGE, msg);
return intents;
}
代码示例来源:origin: qiubiteme/android_api_demos
intents[0] = Intent.makeRestartActivityTask(new ComponentName(this,
com.example.android.apis.ApiDemos.class));
代码示例来源:origin: li2/learning-android-open-source
private PendingIntent makeDefaultIntent() {
// A typical convention for notifications is to launch the user deeply
// into an application representing the data in the notification; to
// accomplish this, we can build an array of intents to insert the back
// stack stack history above the item being displayed.
Intent[] intents = new Intent[4];
// First: root activity of ApiDemos.
// This is a convenient way to make the proper Intent to launch and
// reset an application's task.
intents[0] = Intent.makeRestartActivityTask(new ComponentName(this,
com.example.android.apis.ApiDemos.class));
// "App"
intents[1] = new Intent(this, com.example.android.apis.ApiDemos.class);
intents[1].putExtra("com.example.android.apis.Path", "App");
// "App/Notification"
intents[2] = new Intent(this, com.example.android.apis.ApiDemos.class);
intents[2].putExtra("com.example.android.apis.Path", "App/Notification");
// Now the activity to display to the user.
intents[3] = new Intent(this, StatusBarNotifications.class);
// The PendingIntent to launch our activity if the user selects this
// notification. Note the use of FLAG_UPDATE_CURRENT so that if there
// is already an active matching pending intent, we will update its
// extras (and other Intents in the array) to be the ones passed in here.
PendingIntent contentIntent = PendingIntent.getActivities(this, 0,
intents, PendingIntent.FLAG_UPDATE_CURRENT);
return contentIntent;
}
代码示例来源:origin: qiubiteme/android_api_demos
intents[0] = Intent.makeRestartActivityTask(new ComponentName(this,
com.example.android.apis.ApiDemos.class));
代码示例来源:origin: apptentive/apptentive-android
private static Intent makeRestartActivityTaskGuarded(ComponentName cn) throws InvocationException {
try {
return Intent.makeRestartActivityTask(cn);
} catch (NoSuchMethodError e) {
//return IntentCompat.makeRestartActivityTask(cn);
Invocation invocation = Invocation.fromClass(IntentCompat.class);
return (Intent) invocation.invokeMethod("makeRestartActivityTask", new Class<?>[]{ComponentName.class}, new Object[]{cn});
}
}
代码示例来源:origin: avluis/Hentoid
public static void doRestart(@NonNull Context context) {
try {
PackageManager pm = context.getPackageManager();
if (pm != null) {
Intent intent = pm.getLaunchIntentForPackage(context.getPackageName());
if (intent != null) {
ComponentName componentName = intent.getComponent();
Intent mainIntent = Intent.makeRestartActivityTask(componentName);
mainIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
| Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_CLEAR_TASK);
context.startActivity(mainIntent);
Runtime.getRuntime().exit(0);
} else {
Timber.d("Was not able to restart application, intent null");
}
} else {
Timber.d("Was not able to restart application, PM null");
}
} catch (Exception e) {
Timber.e(e, "Was not able to restart application");
}
}
内容来源于网络,如有侵权,请联系作者删除!