本文整理汇总了Java中android.support.v4.app.TaskStackBuilder类的典型用法代码示例。如果您正苦于以下问题:Java TaskStackBuilder类的具体用法?Java TaskStackBuilder怎么用?Java TaskStackBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TaskStackBuilder类属于android.support.v4.app包,在下文中一共展示了TaskStackBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onOptionsItemSelected
import android.support.v4.app.TaskStackBuilder; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
// Respond to the action bar's Up/Home button
case android.R.id.home:
Intent upIntent = NavUtils.getParentActivityIntent(this);
upIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
if (NavUtils.shouldUpRecreateTask(this, upIntent)) {
// This activity is NOT part of this app's task, so create a new task
// when navigating up, with a synthesized back stack.
TaskStackBuilder.create(this)
// Add all of this activity's parents to the back stack
.addNextIntentWithParentStack(upIntent)
// Navigate up to the closest parent
.startActivities();
} else {
// This activity is part of this app's task, so simply
// navigate up to the logical parent activity.
NavUtils.navigateUpTo(this, upIntent);
}
return true;
}
return super.onOptionsItemSelected(item);
}
示例2: onCreate
import android.support.v4.app.TaskStackBuilder; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TaskStackBuilder builder = TaskStackBuilder.create(this);
Intent proxyIntent = getIntent();
if (!proxyIntent.hasExtra(EXTRA_INTENTS)) {
finish();
return;
}
for (Parcelable parcelable : proxyIntent.getParcelableArrayExtra(EXTRA_INTENTS)) {
builder.addNextIntent((Intent) parcelable);
}
builder.startActivities();
finish();
}
示例3: createViewMessagesPendingIntent
import android.support.v4.app.TaskStackBuilder; //导入依赖的package包/类
public PendingIntent createViewMessagesPendingIntent(Account account, List<MessageReference> messageReferences,
int notificationId) {
TaskStackBuilder stack;
if (account.goToUnreadMessageSearch()) {
stack = buildUnreadBackStack(account);
} else {
String folderId = getFolderIdOfAllMessages(messageReferences);
if (folderId == null) {
stack = buildFolderListBackStack(account);
} else {
stack = buildMessageListBackStack(account, folderId);
}
}
return stack.getPendingIntent(notificationId, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_ONE_SHOT);
}
示例4: sendNotification
import android.support.v4.app.TaskStackBuilder; //导入依赖的package包/类
private void sendNotification(String author, String value) {
// The id of the channel.
String CHANNEL_ID = "jazz_01";
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this, CHANNEL_ID)
.setSmallIcon(R.mipmap.ic_launcher)
.setAutoCancel(true)
.setContentTitle(author)
.setContentText(value);
// Creates an explicit intent for an Activity in your app
Intent resultIntent = new Intent(this, MainActivity.class);
// The stack builder object will contain an artificial back stack for the
// started Activity.
// This ensures that navigating backward from the Activity leads out of
// your app to the Home screen.
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
// Adds the back stack for the Intent (but not the Intent itself)
stackBuilder.addParentStack(MainActivity.class);
// Adds the Intent that starts the Activity to the top of the stack
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent =
stackBuilder.getPendingIntent(
0,
PendingIntent.FLAG_UPDATE_CURRENT
);
mBuilder.setContentIntent(resultPendingIntent);
NotificationManager mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
// mNotificationId is a unique integer your app uses to identify the
// notification. For example, to cancel the notification, you can pass its ID
// number to NotificationManager.cancel().
mNotificationManager.notify(1, mBuilder.build());
}
示例5: startPlacelineScreen
import android.support.v4.app.TaskStackBuilder; //导入依赖的package包/类
private void startPlacelineScreen() {
CrashlyticsWrapper.setCrashlyticsKeys(this);
showProgress(false);
// Clear Existing running trip on Registration Successful
SharedPreferenceManager.deleteAction(this);
SharedPreferenceManager.deletePlace(this);
HyperLog.i(TAG, "User Registration successful: Clearing Active Trip, if any");
Intent intent = new Intent(Profile.this, Placeline.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
TaskStackBuilder.create(Profile.this)
.addNextIntentWithParentStack(intent)
.startActivities();
finish();
}
示例6: startPlacelineScreen
import android.support.v4.app.TaskStackBuilder; //导入依赖的package包/类
private void startPlacelineScreen() {
CrashlyticsWrapper.setCrashlyticsKeys(this);
showProgress(false);
// Clear Existing running trip on Registration Successful
SharedPreferenceManager.deleteAction(this);
SharedPreferenceManager.deletePlace(this);
HyperLog.i(TAG, "User Registration successful: Clearing Active Trip, if any");
Intent intent = new Intent(Verify.this, Placeline.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
TaskStackBuilder.create(Verify.this)
.addNextIntentWithParentStack(intent)
.startActivities();
finish();
}
示例7: handleTrackingDeepLinkError
import android.support.v4.app.TaskStackBuilder; //导入依赖的package包/类
private void handleTrackingDeepLinkError() {
ActionManager actionManager = ActionManager.getSharedManager(this);
//Check if there is any existing task to be restored
if (actionManager.shouldRestoreState()) {
TaskStackBuilder.create(this)
.addNextIntentWithParentStack(new Intent(this, Home.class)
.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
.startActivities();
} else {
TaskStackBuilder.create(this)
.addNextIntentWithParentStack(new Intent(this, Placeline.class)
.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
.startActivities();
}
finish();
actionManager = null;
}
示例8: create_notification
import android.support.v4.app.TaskStackBuilder; //导入依赖的package包/类
private void create_notification(int id, String title, String content) {
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(
(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP
? R.drawable.app_icon_notification : R.drawable.app_icon))
.setContentTitle(title)
.setContentText(content);
Intent resultIntent = new Intent(this, MainActivity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
stackBuilder.addParentStack(MainActivity.class);
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent =
stackBuilder.getPendingIntent(
0,
PendingIntent.FLAG_UPDATE_CURRENT
);
mBuilder.setContentIntent(resultPendingIntent);
NotificationManager mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(id, mBuilder.build());
}
示例9: createNewNoteIntent
import android.support.v4.app.TaskStackBuilder; //导入依赖的package包/类
public static PendingIntent createNewNoteIntent(Context context, Filter filter) {
Intent resultIntent = new Intent(context, ShareActivity.class);
resultIntent.setAction(Intent.ACTION_SEND);
resultIntent.setType("text/plain");
resultIntent.putExtra(Intent.EXTRA_TEXT, "");
if (filter != null && filter.getQuery() != null) {
resultIntent.putExtra(AppIntent.EXTRA_FILTER, filter.getQuery());
}
// The stack builder object will contain an artificial back stack for the
// started Activity.
// This ensures that navigating backward from the Activity leads out of
// your application to the Home screen.
TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
// Adds the back stack for the Intent (but not the Intent itself)
stackBuilder.addParentStack(ShareActivity.class);
// Adds the Intent that starts the Activity to the top of the stack
stackBuilder.addNextIntent(resultIntent);
// return PendingIntent.getActivity(context, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT);
return stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
}
示例10: onCreate
import android.support.v4.app.TaskStackBuilder; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
if (sharedPref.getBoolean(SettingsActivity.KEY_COLLECTE_ACTIVER, false)) {
SharedPreferences.Editor editor = sharedPref.edit();
editor.putBoolean(SettingsActivity.KEY_COLLECTE_ACTIVER, false);
editor.commit();
}
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
stackBuilder.addNextIntent(new Intent(this, MainActivity.class));
stackBuilder.addParentStack(MainActivity.class);
stackBuilder.startActivities();
}
示例11: onCreate
import android.support.v4.app.TaskStackBuilder; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
// Check if Driver is logged in currently
String driverId = SharedPreferenceStore.getDriverId(this);
if (TextUtils.isEmpty(driverId)) {
// Initiate Driver Login by starting LoginActivity
TaskStackBuilder.create(SplashScreen.this)
.addNextIntentWithParentStack(new Intent(SplashScreen.this, LoginActivity.class)
.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
.startActivities();
finish();
} else {
// Start Driver Session by starting MainActivity
TaskStackBuilder.create(SplashScreen.this)
.addNextIntentWithParentStack(new Intent(SplashScreen.this, MainActivity.class)
.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
.startActivities();
finish();
}
}
示例12: navigateUpOrBack
import android.support.v4.app.TaskStackBuilder; //导入依赖的package包/类
/**
* This utility method handles Up navigation intents by searching for a parent activity and
* navigating there if defined. When using this for an activity make sure to define both the
* native parentActivity as well as the AppCompat one when supporting API levels less than 16.
* when the activity has a single parent activity. If the activity doesn't have a single parent
* activity then don't define one and this method will use back button functionality. If "Up"
* functionality is still desired for activities without parents then use
* {@code syntheticParentActivity} to define one dynamically.
*
* Note: Up navigation intents are represented by a back arrow in the top left of the Toolbar
* in Material Design guidelines.
*
* @param currentActivity Activity in use when navigate Up action occurred.
* @param syntheticParentActivity Parent activity to use when one is not already configured.
*/
public static void navigateUpOrBack(Activity currentActivity,
Class<? extends Activity> syntheticParentActivity) {
// Retrieve parent activity from AndroidManifest.
Intent intent = NavUtils.getParentActivityIntent(currentActivity);
// Synthesize the parent activity when a natural one doesn't exist.
if (intent == null && syntheticParentActivity != null) {
try {
intent = NavUtils.getParentActivityIntent(currentActivity, syntheticParentActivity);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
}
if (intent == null) {
// No parent defined in manifest. This indicates the activity may be used by
// in multiple flows throughout the app and doesn't have a strict parent. In
// this case the navigation up button should act in the same manner as the
// back button. This will result in users being forwarded back to other
// applications if currentActivity was invoked from another application.
currentActivity.onBackPressed();
} else {
if (NavUtils.shouldUpRecreateTask(currentActivity, intent)) {
// Need to synthesize a backstack since currentActivity was probably invoked by a
// different app. The preserves the "Up" functionality within the app according to
// the activity hierarchy defined in AndroidManifest.xml via parentActivity
// attributes.
TaskStackBuilder builder = TaskStackBuilder.create(currentActivity);
builder.addNextIntentWithParentStack(intent);
builder.startActivities();
} else {
// Navigate normally to the manifest defined "Up" activity.
NavUtils.navigateUpTo(currentActivity, intent);
}
}
}
示例13: onOptionsItemSelected
import android.support.v4.app.TaskStackBuilder; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
Intent upIntent = new Intent(this, MainActivity.class);
if (NavUtils.shouldUpRecreateTask(this, upIntent)) {
// This activity is not part of the application's task, so create a new task
// with a synthesized back stack.
TaskStackBuilder.from(this)
.addNextIntent(upIntent)
.startActivities();
finish();
} else {
// This activity is part of the application's task, so simply
// navigate up to the hierarchical parent activity.
NavUtils.navigateUpTo(this, upIntent);
}
return true;
} else if (item.getTitle().equals("Settings")) {
//startActivity(new Intent(this, Settings.class));
finish();
// overridePendingTransition(R.anim.hold, R.anim.push_out_to_left);
return true;
}
return super.onOptionsItemSelected(item);
}
示例14: showStartNotification
import android.support.v4.app.TaskStackBuilder; //导入依赖的package包/类
private void showStartNotification() {
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle(getString(R.string.file_scanner))
.setContentText(getString(R.string.scan_started))
.setTicker(getString(R.string.file_scan_started))
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
Intent resultIntent = new Intent(this, MainActivity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
stackBuilder.addParentStack(MainActivity.class);
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent =
stackBuilder.getPendingIntent(
0,
PendingIntent.FLAG_UPDATE_CURRENT
);
mBuilder.setContentIntent(resultPendingIntent);
NotificationManager mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(0, mBuilder.build());
}
示例15: sendEvaluationNotification
import android.support.v4.app.TaskStackBuilder; //导入依赖的package包/类
private void sendEvaluationNotification(){
NotificationCompat.Builder mBuilder =
(NotificationCompat.Builder) new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.trezentos_icon)
.setContentTitle("Avaliação")
.setContentText("Você tem avaliações à serem feitas!")
.setLargeIcon(BitmapFactory.decodeResource(getResources()
, R.drawable.trezentos_icon));
Intent resultIntent = new Intent(this, MainActivity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
stackBuilder.addParentStack(MainActivity.class);
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent =
stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent(resultPendingIntent);
NotificationManager mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(0, mBuilder.build());
}