當前位置: 首頁>>代碼示例>>Java>>正文


Java TaskStackBuilder.addParentStack方法代碼示例

本文整理匯總了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);
}
 
開發者ID:pedromassango,項目名稱:Programmers,代碼行數:14,代碼來源:CustomNotification.java

示例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());
}
 
開發者ID:SiniTurk,項目名稱:OTAUpdates,代碼行數:24,代碼來源:MainActivity.java

示例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);
    }
 
開發者ID:orgzly,項目名稱:orgzly-android,代碼行數:24,代碼來源:ShareActivity.java

示例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();
}
 
開發者ID:ANFR-France,項目名稱:proto-collecte,代碼行數:17,代碼來源:StopCollecteActivity.java

示例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());

    }
 
開發者ID:SecUSo,項目名稱:privacy-friendly-todo-list,代碼行數:25,代碼來源:ReminderService.java

示例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());
}
 
開發者ID:ello,項目名稱:ello-android,代碼行數:25,代碼來源:ElloGcmListenerService.java

示例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());
}
 
開發者ID:cscd-488,項目名稱:event-app,代碼行數:24,代碼來源:Notification.java

示例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);
}
 
開發者ID:xavierle,項目名稱:messengerxmpp,代碼行數:25,代碼來源:NotificationService.java

示例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);
}
 
開發者ID:SebastianRask,項目名稱:Pocket-Plays-for-Twitch,代碼行數:18,代碼來源:VideoCastNotificationService.java

示例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());

}
 
開發者ID:PaulKlinger,項目名稱:Sprog-App,代碼行數:36,代碼來源:MessagingService.java

示例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++;
    }
}
 
開發者ID:kamisakihideyoshi,項目名稱:TaipeiTechRefined,代碼行數:35,代碼來源:Utility.java

示例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());
}
 
開發者ID:vshkl,項目名稱:SaveIg,代碼行數:16,代碼來源:NotificationHelper.java

示例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++;
}
 
開發者ID:kamisakihideyoshi,項目名稱:TaipeiTechRefined,代碼行數:32,代碼來源:Utility.java

示例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());
	}
}
 
開發者ID:rafjordao,項目名稱:Nird2,代碼行數:39,代碼來源:AndroidNotificationManagerImpl.java

示例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
  );
}
 
開發者ID:dr0id3v,項目名稱:QuotesOnDesign,代碼行數:15,代碼來源:DefaultNotificationsPresenter.java


注:本文中的android.support.v4.app.TaskStackBuilder.addParentStack方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。