本文整理汇总了Java中android.support.v4.app.TaskStackBuilder.create方法的典型用法代码示例。如果您正苦于以下问题:Java TaskStackBuilder.create方法的具体用法?Java TaskStackBuilder.create怎么用?Java TaskStackBuilder.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.app.TaskStackBuilder
的用法示例。
在下文中一共展示了TaskStackBuilder.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例2: 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());
}
示例3: onSupportNavigateUp
import android.support.v4.app.TaskStackBuilder; //导入方法依赖的package包/类
public boolean onSupportNavigateUp() {
Intent upIntent = getSupportParentActivityIntent();
if (upIntent == null) {
return false;
}
if (supportShouldUpRecreateTask(upIntent)) {
TaskStackBuilder b = TaskStackBuilder.create(this);
onCreateSupportNavigateUpTaskStack(b);
onPrepareSupportNavigateUpTaskStack(b);
b.startActivities();
try {
ActivityCompat.finishAffinity(this);
} catch (IllegalStateException e) {
finish();
}
} else {
supportNavigateUpTo(upIntent);
}
return true;
}
示例4: 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);
}
示例5: sendNotification
import android.support.v4.app.TaskStackBuilder; //导入方法依赖的package包/类
private void sendNotification(String title, String body, String webUrl) {
NotificationCompat.Builder builder =
(NotificationCompat.Builder) new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_stat_gcm)
.setContentTitle(title)
.setContentText(body);
Intent resultIntent = new Intent(getApplicationContext(), MainActivity.class);
resultIntent.putExtra("web_url", webUrl);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
stackBuilder.addParentStack(MainActivity.class);
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent =
stackBuilder.getPendingIntent(
0,
PendingIntent.FLAG_CANCEL_CURRENT
);
builder.setContentIntent(resultPendingIntent);
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(NOTIFICATION_ID, builder.build());
}
示例6: onClick
import android.support.v4.app.TaskStackBuilder; //导入方法依赖的package包/类
@Override
public void onClick(View v) {
// This ID represents the Home or Up button. In the case of this
// activity, the Up button is shown. Use NavUtils to allow users
// to navigate up one level in the application structure. For
// more details, see the Navigation pattern on Android Design:
//
// http://developer.android.com/design/patterns/navigation.html#up-vs-back
//
final Intent listIntent = new Intent(this, PostItemListActivity.class);
if (NavUtils.shouldUpRecreateTask(this, listIntent)) {
final TaskStackBuilder taskStack = TaskStackBuilder.create(this);
taskStack.addNextIntent(listIntent);
taskStack.startActivities();
} else {
NavUtils.navigateUpTo(this, listIntent);
}
}
示例7: showActivityNotification
import android.support.v4.app.TaskStackBuilder; //导入方法依赖的package包/类
public static void showActivityNotification(Context context, String title,
String message, Bitmap bitmap){
if (context == null) {
return;
}
NotificationCompat.Builder builder = new NotificationCompat.Builder(
context);
builder.setContentTitle(title)
.setContentText(message)
.setSmallIcon(R.drawable.activity_icon)
.setLargeIcon(BitmapUtility.loadBitmap(context, R.drawable.ic_app))
.setStyle(
new NotificationCompat
.BigPictureStyle()
.bigPicture(bitmap)
.setSummaryText(message));
Intent intent = new Intent(context, MainActivity.class);
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
TaskStackBuilder stack_builder = TaskStackBuilder.create(context);
stack_builder.addParentStack(MainActivity.class);
stack_builder.addNextIntent(intent);
PendingIntent pending_intent = stack_builder
.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(pending_intent);
NotificationManager notify_manager = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
notify_manager.notify(notification_index, builder.build());
notification_index++;
}
示例8: createNotification
import android.support.v4.app.TaskStackBuilder; //导入方法依赖的package包/类
private void createNotification(int new_poems_count)
{
String notification_title;
if (new_poems_count>10){
notification_title = "More than 10 new poems available!";
} else {
notification_title = String.format("%d new poem%s available!",
new_poems_count, new_poems_count > 1 ? "s" : "");
}
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_stat_fleuronwhite)
.setContentTitle(notification_title)
.setContentText("Tap to view.")
.setColor(ContextCompat.getColor(this, R.color.colorLauncherIcon))
.setAutoCancel(false)
.setLights(Color.GREEN, 400, 3000);
Intent mainIntent = new Intent(this, MainActivity.class);
mainIntent.putExtra("UPDATE", true);
NotificationManager mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
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(mainIntent);
PendingIntent resultPendingIntent =
stackBuilder.getPendingIntent(
0,
PendingIntent.FLAG_UPDATE_CURRENT
);
mBuilder.setContentIntent(resultPendingIntent);
// If a previous notification is still visible it is updated automatically
mNotificationManager.notify(NEW_POEMS_NOTIFICATION_ID, mBuilder.build());
}
示例9: createContentIntent
import android.support.v4.app.TaskStackBuilder; //导入方法依赖的package包/类
/** Create activity launch on notification click intent. */
private PendingIntent createContentIntent()
{
Intent intent = new Intent( app, SplashActivity.class );
int requestId = (int) System.currentTimeMillis();
// Use TaskStackBuilder to make activity go back
// to Home screen, when navigating back from it
TaskStackBuilder stackBuilder = TaskStackBuilder.create( app );
stackBuilder.addParentStack( SplashActivity.class );
stackBuilder.addNextIntent( intent );
return stackBuilder.getPendingIntent(
requestId, PendingIntent.FLAG_UPDATE_CURRENT
);
}
示例10: updateIntroductionNotification
import android.support.v4.app.TaskStackBuilder; //导入方法依赖的package包/类
@UiThread
private void updateIntroductionNotification() {
NotificationCompat.Builder b =
new NotificationCompat.Builder(appContext);
b.setSmallIcon(R.drawable.notification_introduction);
b.setColor(ContextCompat.getColor(appContext, R.color.briar_primary));
b.setContentTitle(appContext.getText(R.string.app_name));
b.setContentText(appContext.getResources().getQuantityString(
R.plurals.introduction_notification_text, introductionTotal,
introductionTotal));
String ringtoneUri = settings.get(PREF_NOTIFY_RINGTONE_URI);
if (!StringUtils.isNullOrEmpty(ringtoneUri))
b.setSound(Uri.parse(ringtoneUri));
b.setDefaults(getDefaults());
b.setOnlyAlertOnce(true);
b.setAutoCancel(true);
// Touching the notification shows the contact list
Intent i = new Intent(appContext, NavDrawerActivity.class);
i.putExtra(INTENT_CONTACTS, true);
i.setFlags(FLAG_ACTIVITY_CLEAR_TOP);
i.setData(Uri.parse(CONTACT_URI));
TaskStackBuilder t = TaskStackBuilder.create(appContext);
t.addParentStack(NavDrawerActivity.class);
t.addNextIntent(i);
b.setContentIntent(t.getPendingIntent(nextRequestId++, 0));
if (Build.VERSION.SDK_INT >= 21) {
b.setCategory(CATEGORY_MESSAGE);
b.setVisibility(VISIBILITY_SECRET);
}
Object o = appContext.getSystemService(NOTIFICATION_SERVICE);
NotificationManager nm = (NotificationManager) o;
nm.notify(INTRODUCTION_SUCCESS_NOTIFICATION_ID, b.build());
}
示例11: updateBlogPostNotification
import android.support.v4.app.TaskStackBuilder; //导入方法依赖的package包/类
@UiThread
private void updateBlogPostNotification() {
if (blogTotal == 0) {
clearBlogPostNotification();
} else if (settings.getBoolean(PREF_NOTIFY_BLOG, true)) {
NotificationCompat.Builder b =
new NotificationCompat.Builder(appContext);
b.setSmallIcon(R.drawable.notification_blog);
b.setColor(ContextCompat.getColor(appContext,
R.color.briar_primary));
b.setContentTitle(appContext.getText(R.string.app_name));
b.setContentText(appContext.getResources().getQuantityString(
R.plurals.blog_post_notification_text, blogTotal,
blogTotal));
String ringtoneUri = settings.get(PREF_NOTIFY_RINGTONE_URI);
if (!StringUtils.isNullOrEmpty(ringtoneUri))
b.setSound(Uri.parse(ringtoneUri));
b.setDefaults(getDefaults());
b.setOnlyAlertOnce(true);
b.setAutoCancel(true);
// Touching the notification shows the combined blog feed
Intent i = new Intent(appContext, NavDrawerActivity.class);
i.putExtra(INTENT_BLOGS, true);
i.setFlags(FLAG_ACTIVITY_CLEAR_TOP);
i.setData(Uri.parse(BLOG_URI));
TaskStackBuilder t = TaskStackBuilder.create(appContext);
t.addParentStack(NavDrawerActivity.class);
t.addNextIntent(i);
b.setContentIntent(t.getPendingIntent(nextRequestId++, 0));
if (Build.VERSION.SDK_INT >= 21) {
b.setCategory(CATEGORY_SOCIAL);
b.setVisibility(VISIBILITY_SECRET);
}
Object o = appContext.getSystemService(NOTIFICATION_SERVICE);
NotificationManager nm = (NotificationManager) o;
nm.notify(BLOG_POST_NOTIFICATION_ID, b.build());
}
}
示例12: showNotification
import android.support.v4.app.TaskStackBuilder; //导入方法依赖的package包/类
/**
* Displays a notification with the location results.
*/
void showNotification() {
Intent notificationIntent = new Intent(mContext, MainActivity.class);
// Construct a task stack.
TaskStackBuilder stackBuilder = TaskStackBuilder.create(mContext);
// Add the main Activity to the task stack as the parent.
stackBuilder.addParentStack(MainActivity.class);
// Push the content Intent onto the stack.
stackBuilder.addNextIntent(notificationIntent);
// Get a PendingIntent containing the entire back stack.
PendingIntent notificationPendingIntent =
stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
Notification.Builder notificationBuilder = new Notification.Builder(mContext,
PRIMARY_CHANNEL)
.setContentTitle(getLocationResultTitle())
.setContentText(getLocationResultText())
.setSmallIcon(R.mipmap.ic_launcher)
.setAutoCancel(true)
.setContentIntent(notificationPendingIntent);
getNotificationManager().notify(0, notificationBuilder.build());
}
开发者ID:googlecodelabs,项目名称:background-location-updates-android-o,代码行数:30,代码来源:LocationResultHelper.java
示例13: fireBanner
import android.support.v4.app.TaskStackBuilder; //导入方法依赖的package包/类
private static void fireBanner(Uri sound) {
final Activity curr = getActivity();
if (curr != null) {
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(curr)
.setSmallIcon(R.mipmap.ic_launcher)
.setAutoCancel(true)
.setSound(sound)
.setLargeIcon(BitmapFactory.decodeResource(curr.getResources(), R.mipmap.ic_launcher_large))
.setContentTitle(curr.getResources().getString(R.string.app_name))
.setContentText("Your timetable changed!");
if (sound != null) {
mBuilder.setSound(sound);
}
// Creates an explicit intent for an Activity in your app
Intent resultIntent = new Intent(curr, curr.getClass());
// 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(curr);
// Adds the back stack for the Intent (but not the Intent itself)
stackBuilder.addParentStack(curr.getClass());
// 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)
curr.getSystemService(Context.NOTIFICATION_SERVICE);
// mId allows you to update the notification later on.
if (mNotificationManager != null) {
mNotificationManager.notify(1337, mBuilder.build());
}
}
}
示例14: showNotification
import android.support.v4.app.TaskStackBuilder; //导入方法依赖的package包/类
static void showNotification(final Context context) {
TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
stackBuilder.addParentStack(MainActivity.class);
stackBuilder.addNextIntent(new Intent(context, MainActivity.class));
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
.setOngoing(true)
.setSmallIcon(R.drawable.ic_instagram_download)
.setContentTitle(context.getString(R.string.notification_title))
.setContentText(context.getString(R.string.notification_content))
.setContentIntent(stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT));
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(NOTIFICATION_ID, builder.build());
}
示例15: showSyncNotification
import android.support.v4.app.TaskStackBuilder; //导入方法依赖的package包/类
private void showSyncNotification() {
DebugLog.logMethod();
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
.setContentTitle(contentTitle)
.setContentText(contentText)
.setWhen(System.currentTimeMillis())
.setLargeIcon(Utilities.getBitmap(context, largeIconId))
.setSmallIcon(smallIconId)
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
.setAutoCancel(true);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
stackBuilder.addNextIntent(new Intent(context, CouponListActivity.class));
PendingIntent contentPendingIntent = stackBuilder.getPendingIntent(
0,
PendingIntent.FLAG_UPDATE_CURRENT
);
builder.setContentIntent(contentPendingIntent);
// Cancel any previously shown notification
NotificationManagerCompat.from(context).cancel(TAG, SYNC_NOTIFICATION_ID);
// Show notification
NotificationManagerCompat.from(context).notify(
TAG,
SYNC_NOTIFICATION_ID,
builder.build()
);
}