当前位置: 首页>>代码示例>>Java>>正文


Java TaskStackBuilder.getPendingIntent方法代码示例

本文整理汇总了Java中android.support.v4.app.TaskStackBuilder.getPendingIntent方法的典型用法代码示例。如果您正苦于以下问题:Java TaskStackBuilder.getPendingIntent方法的具体用法?Java TaskStackBuilder.getPendingIntent怎么用?Java TaskStackBuilder.getPendingIntent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v4.app.TaskStackBuilder的用法示例。


在下文中一共展示了TaskStackBuilder.getPendingIntent方法的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: 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());
}
 
开发者ID:coe-google-apps-support,项目名称:jazz-android,代码行数:36,代码来源:MainActivity.java

示例3: 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());
}
 
开发者ID:steveyangmoto,项目名称:file_scanner,代码行数:23,代码来源:MainActivity.java

示例4: 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

示例5: 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

示例6: 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());
}
 
开发者ID:fga-gpp-mds,项目名称:2017.1-Trezentos,代码行数:25,代码来源:ExamActivity.java

示例7: 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

示例8: 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

示例9: projectUpdateContentIntent

import android.support.v4.app.TaskStackBuilder; //导入方法依赖的package包/类
private @NonNull PendingIntent projectUpdateContentIntent(final @NonNull PushNotificationEnvelope envelope,
  final @NonNull Update update, final @NonNull String projectParam) {

  final Intent projectIntent = new Intent(this.context, ProjectActivity.class)
    .putExtra(IntentKey.PROJECT_PARAM, projectParam);

  final Intent updateIntent = new Intent(this.context, UpdateActivity.class)
    .putExtra(IntentKey.PROJECT_PARAM, projectParam)
    .putExtra(IntentKey.UPDATE, update)
    .putExtra(IntentKey.PUSH_NOTIFICATION_ENVELOPE, envelope);

  final TaskStackBuilder taskStackBuilder = TaskStackBuilder.create(this.context)
    .addNextIntentWithParentStack(projectIntent)
    .addNextIntent(updateIntent);

  return taskStackBuilder.getPendingIntent(envelope.signature(), PendingIntent.FLAG_UPDATE_CURRENT);
}
 
开发者ID:kickstarter,项目名称:android-oss,代码行数:18,代码来源:PushNotifications.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: notification

import android.support.v4.app.TaskStackBuilder; //导入方法依赖的package包/类
private Notification notification(CrashViewModel crashViewModel) {
  Intent crashActivityIntent = new Intent(context, CrashActivity.class);
  crashActivityIntent.putExtra(CrashActivity.CRASH_ID, crashViewModel.getIdentifier());

  TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
  stackBuilder.addParentStack(CrashActivity.class);
  stackBuilder.addNextIntent(crashActivityIntent);

  PendingIntent pendingIntent = stackBuilder.getPendingIntent(221, FLAG_UPDATE_CURRENT);

  Notification.Builder notificationBuilder = new Notification.Builder(context)
      .setContentTitle(crashViewModel.getPlace())
      .setContentText(crashViewModel.getDate())
      .setSmallIcon(R.mipmap.ic_stat_sherlock_logo)
      .setContentIntent(pendingIntent)
      .setAutoCancel(true);

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    notificationBuilder.setColor(ContextCompat.getColor(context, R.color.sherlock_colorAccent));
  }

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
    notificationBuilder.setChannelId(CHANNEL_ID);
  }

  return notificationBuilder.build();
}
 
开发者ID:ajitsing,项目名称:Sherlock,代码行数:28,代码来源:CrashReporter.java

示例12: onCreate

import android.support.v4.app.TaskStackBuilder; //导入方法依赖的package包/类
@Override
public void onCreate() {
    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    /* Unneeded due to setAutoCancel(true):

    Intent onNotificationDeletedIntent = new Intent(getApplicationContext(), OnNotificationDeletedReceiver.class);
    PendingIntent onNotificationDeletedPendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0,
                onNotificationDeletedIntent, 0);*/
    NotificationCompat.Builder reminderBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.ic_statusbar)
            .setContentTitle(getString(R.string.reminder_title))
            .setContentText(getString(R.string.reminder_description))
            .setPriority(NotificationCompat.PRIORITY_LOW)
            //.setDeleteIntent(onNotificationDeletedPendingIntent)
            .setAutoCancel(true);
    Intent inputIntent = new Intent(this , InputActivity.class);
    Intent overviewIntent = new Intent(this , OverviewActivity.class);
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(this)
        .addNextIntentWithParentStack(overviewIntent)
        .addNextIntentWithParentStack(inputIntent);
    PendingIntent inputPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);

    inputIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
    inputIntent.putExtra(ViewConstants.CALLER_ACTIVITY, ViewConstants.OVERVIEW_ACTIVITY);
    reminderBuilder.setContentIntent(inputPendingIntent);
    notificationManager.notify(NOTIFICATION_ID_REMINDER, reminderBuilder.build());

    PreferencesAccess.storeDate(getApplicationContext(), PreferencesAccess.NOTIFICATION_PREFS,
            PreferencesAccess.KEY_DATE_REMINDER_LAST_SHOWN, Calendar.getInstance().getTime());

    stopSelf();
}
 
开发者ID:mr-kojo,项目名称:Veggietizer,代码行数:33,代码来源:NotificationService.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());
        }
    }
}
 
开发者ID:dhbw-timetable,项目名称:dhbw-timetable-android,代码行数:40,代码来源:TimetableManager.java

示例14: buildPendingIntent

import android.support.v4.app.TaskStackBuilder; //导入方法依赖的package包/类
private PendingIntent buildPendingIntent(Uri video) {
	Intent detailsIntent = new Intent(Intent.ACTION_VIEW);
	detailsIntent.setData(video);
	detailsIntent.putExtra(PlayerActivity.RESUME, PlayerActivity.RESUME_FROM_LAST_POS);
	detailsIntent.setClass(this, PlayerActivity.class);
	TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
	stackBuilder.addParentStack(PlayerActivity.class);
	stackBuilder.addNextIntent(detailsIntent);
	// Ensure a unique PendingIntents, otherwise all
	// recommendations end up with the same PendingIntent
	PendingIntent intent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);

	return intent;
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:15,代码来源:UpdateRecommendationsService.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.getPendingIntent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。