本文整理汇总了Java中android.support.v4.app.TaskStackBuilder.addParentStack方法的典型用法代码示例。如果您正苦于以下问题:Java TaskStackBuilder.addParentStack方法的具体用法?Java TaskStackBuilder.addParentStack怎么用?Java TaskStackBuilder.addParentStack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.app.TaskStackBuilder
的用法示例。
在下文中一共展示了TaskStackBuilder.addParentStack方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCommentPendingIntent
import android.support.v4.app.TaskStackBuilder; //导入方法依赖的package包/类
private PendingIntent getCommentPendingIntent(Bundle b) {
// Intent to open Comments Activity
TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
stackBuilder.addParentStack(CommentsActivity.class);
Intent commentsIntent = IntentUtils.getIntent(context, CommentsActivity.class);
commentsIntent.putExtras(b);
stackBuilder.addNextIntent(commentsIntent);
// Set the pendingIntent on Notification.Builder
//PendingIntent pendingIntent = PendingIntent.getActivity(context, id, commentsIntent, PendingIntent.FLAG_UPDATE_CURRENT);
return stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
}
示例2: 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());
}
示例3: 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);
}
示例4: 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();
}
示例5: handleAlarm
import android.support.v4.app.TaskStackBuilder; //导入方法依赖的package包/类
private void handleAlarm(TodoTask task) {
String title = task.getName();
Intent resultIntent = new Intent(this, MainActivity.class);
resultIntent.putExtra(MainActivity.KEY_SELECTED_FRAGMENT_BY_NOTIFICATION, TodoTasksFragment.KEY);
resultIntent.putExtra(TodoTask.PARCELABLE_KEY, task);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);
mBuilder.setSmallIcon(android.R.drawable.ic_lock_idle_alarm);
mBuilder.setContentTitle(title);
if(task.hasDeadline())
mBuilder.setContentText(getResources().getString(R.string.deadline_approaching, Helper.getDateTime(task.getDeadline())));
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
stackBuilder.addParentStack(MainActivity.class);
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent(resultPendingIntent);
mBuilder.setAutoCancel(true);
mBuilder.setLights(ContextCompat.getColor(this, R.color.colorPrimary), 1000, 500);
mNotificationManager.notify(task.getId(), mBuilder.build());
}
示例6: 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());
}
示例7: create
import android.support.v4.app.TaskStackBuilder; //导入方法依赖的package包/类
public static void create(Context context, int id, String name, String description, long ... vibrateTime){
NotificationCompat.Builder mBuilder = (NotificationCompat.Builder) new NotificationCompat.Builder(context).setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle(name)
.setContentText(description);
mBuilder.setVibrate(vibrateTime);
mBuilder.setLights(color, colorDuration, colorDuration);
Intent notIntent = new Intent(context, MainActivity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
stackBuilder.addParentStack(MainActivity.class);
stackBuilder.addNextIntent(notIntent);
PendingIntent resultPendingIntent =
stackBuilder.getPendingIntent(
0,
PendingIntent.FLAG_UPDATE_CURRENT
);
mBuilder.setContentIntent(resultPendingIntent);
NotificationManager mNotificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
// mId allows you to update the notification later on.
mNotificationManager.notify(id, mBuilder.build());
}
示例8: createContentIntent
import android.support.v4.app.TaskStackBuilder; //导入方法依赖的package包/类
private PendingIntent createContentIntent(final String conversationUuid, final String downloadMessageUuid) {
final TaskStackBuilder stackBuilder = TaskStackBuilder
.create(mXmppConnectionService);
stackBuilder.addParentStack(ConversationActivity.class);
final Intent viewConversationIntent = new Intent(mXmppConnectionService,
ConversationActivity.class);
if (downloadMessageUuid != null) {
viewConversationIntent.setAction(ConversationActivity.ACTION_DOWNLOAD);
} else {
viewConversationIntent.setAction(Intent.ACTION_VIEW);
}
if (conversationUuid != null) {
viewConversationIntent.putExtra(ConversationActivity.CONVERSATION, conversationUuid);
viewConversationIntent.setType(ConversationActivity.VIEW_CONVERSATION);
}
if (downloadMessageUuid != null) {
viewConversationIntent.putExtra(ConversationActivity.MESSAGE, downloadMessageUuid);
}
stackBuilder.addNextIntent(viewConversationIntent);
return stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
}
示例9: getContentIntent
import android.support.v4.app.TaskStackBuilder; //导入方法依赖的package包/类
/**
* Returns the {@link PendingIntent} for showing the full screen cast controller page. We also
* build an appropriate "back stack" so that when user is sent to that full screen controller,
* clicking on the Back button would allow navigation into the app.
*/
protected PendingIntent getContentIntent(MediaInfo mediaInfo) {
Bundle mediaWrapper = Utils.mediaInfoToBundle(mediaInfo);
Intent contentIntent = new Intent(this, mTargetActivity);
contentIntent.putExtra(VideoCastManager.EXTRA_MEDIA, mediaWrapper);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
stackBuilder.addParentStack(mTargetActivity);
stackBuilder.addNextIntent(contentIntent);
if (stackBuilder.getIntentCount() > 1) {
stackBuilder.editIntentAt(1).putExtra(VideoCastManager.EXTRA_MEDIA, mediaWrapper);
}
return stackBuilder.getPendingIntent(NOTIFICATION_ID, PendingIntent.FLAG_UPDATE_CURRENT);
}
示例10: 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());
}
示例11: showNotification
import android.support.v4.app.TaskStackBuilder; //导入方法依赖的package包/类
public static void showNotification(Context context, String title,
String message, boolean is_hint) {
if (context == null) {
return;
}
NotificationCompat.Builder builder = new NotificationCompat.Builder(
context);
builder.setStyle(
new NotificationCompat
.BigTextStyle(builder)
.bigText(message)
.setBigContentTitle(title))
.setContentTitle(title)
.setContentText(message)
.setSmallIcon(R.drawable.ic_notification)
.setTicker(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(is_hint ? hint_notification_index
: notification_index, builder.build());
if (!is_hint) {
notification_index++;
}
}
示例12: 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());
}
示例13: 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++;
}
示例14: 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());
}
}
示例15: 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
);
}