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


Java TaskStackBuilder.getPendingIntent方法代码示例

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


在下文中一共展示了TaskStackBuilder.getPendingIntent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createAuthNotification

import android.app.TaskStackBuilder; //导入方法依赖的package包/类
private void createAuthNotification()
{
    NotificationCompat.Builder builder =
            new NotificationCompat.Builder(getContext(), AuthenticatorActivity.AUTH_NOTIFICATION_CHANNEL_ID)
                .setContentTitle(getContext().getString(R.string.sync_ntf_needs_reauthentication_title))
                .setContentText(getContext().getString(R.string.sync_ntf_needs_reauthentication_description))
                .setSmallIcon(R.mipmap.ic_launcher)
                .setAutoCancel(true);

    Intent intent = new Intent(getContext(), AuthenticatorActivity.class);
    intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, getContext().getString(R.string.account_type));
    intent.putExtra(AuthenticatorActivity.ARG_AUTH_TOKEN_TYPE, AuthenticatorActivity.ARG_AUTH_TOKEN_TYPE);
    intent.putExtra(AuthenticatorActivity.ARG_IS_ADDING_NEW_ACCOUNT, false);

    TaskStackBuilder stackBuilder = TaskStackBuilder.create(getContext());
    stackBuilder.addParentStack(AuthenticatorActivity.class);
    stackBuilder.addNextIntent(intent);
    PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
    builder.setContentIntent(resultPendingIntent);

    NotificationManager ntfMgr =
            (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE);
    ntfMgr.notify(AuthenticatorActivity.AUTH_NOTIFICATION_ID, builder.build());
}
 
开发者ID:danvratil,项目名称:FBEventSync,代码行数:25,代码来源:CalendarSyncAdapter.java

示例2: sendNodeOfflineNotification

import android.app.TaskStackBuilder; //导入方法依赖的package包/类
private void sendNodeOfflineNotification(StorjNode storjNode) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext);
    if(prefs.getBoolean(mContext.getString(R.string.pref_enable_notifications),true)) {
        TaskStackBuilder stackBuilder = TaskStackBuilder.create(mContext);

        Intent detailNotificationIntent = new Intent(mContext, StorjNodeDetailActivity.class);
        detailNotificationIntent.putExtra(StorjNodeDetailActivity.EXTRA_NODEID, storjNode.getNodeID().getValue());
        stackBuilder.addNextIntentWithParentStack(detailNotificationIntent);

        PendingIntent operation = stackBuilder.getPendingIntent(storjNode.getNodeID().getValue().hashCode(), PendingIntent.FLAG_CANCEL_CURRENT);

        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mContext)
                .setSmallIcon(R.drawable.storj_symbol)
                .setContentTitle(storjNode.getSimpleName().getValue())
                .setContentIntent(operation)
                .setContentText(mContext.getString(R.string.node_is_offline, storjNode.getSimpleName().getValue()));

        NotificationManager mNotificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
        mNotificationManager.notify(storjNode.getNodeID().hashCode(), mBuilder.build());
    }
}
 
开发者ID:geckogecko,项目名称:storj_hoststats_app,代码行数:22,代码来源:AlarmReceiver.java

示例3: sendNewUserAgentVersionNotification

import android.app.TaskStackBuilder; //导入方法依赖的package包/类
private void sendNewUserAgentVersionNotification() {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext);
    if(prefs.getBoolean(mContext.getString(R.string.pref_enable_notifications),true)) {
        TaskStackBuilder stackBuilder = TaskStackBuilder.create(mContext);
        stackBuilder.addNextIntentWithParentStack(new Intent(mContext, MainActivity.class));

        PendingIntent operation = stackBuilder.getPendingIntent(1, PendingIntent.FLAG_CANCEL_CURRENT);

        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mContext)
                .setSmallIcon(R.drawable.storj_symbol)
                .setContentTitle(mContext.getResources().getString(R.string.new_useragent_version))
                .setContentIntent(operation)
                .setContentText(mContext.getResources().getString(R.string.new_useragent_version_details));

        NotificationManager mNotificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
        mNotificationManager.notify(1, mBuilder.build());
    }
}
 
开发者ID:geckogecko,项目名称:storj_hoststats_app,代码行数:19,代码来源:AlarmReceiver.java

示例4: reminder

import android.app.TaskStackBuilder; //导入方法依赖的package包/类
void reminder()
    {

        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);

        mBuilder.setSmallIcon(R.drawable.sos);
        mBuilder.setContentTitle("Reminder !");
        mBuilder.setContentText(reminder_text);

        Intent resultIntent = new Intent(this, Location_event.class);
        TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
        stackBuilder.addParentStack(Location_event.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);

// notificationID allows you to update the notification later on.
        mNotificationManager.notify(0, mBuilder.build());

    }
 
开发者ID:SkylineLabs,项目名称:FindX,代码行数:25,代码来源:digiPune.java

示例5: sendNotification

import android.app.TaskStackBuilder; //导入方法依赖的package包/类
private void sendNotification() {
    NotificationCompat.Builder builder =
            new NotificationCompat.Builder(this)
                    .setContentTitle("Beacon Reference Application")
                    .setContentText("An beacon is nearby.")
                    .setSmallIcon(R.drawable.ic_launcher);

    TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
    stackBuilder.addNextIntent(new Intent(this, MonitoringActivity.class));
    PendingIntent resultPendingIntent =
            stackBuilder.getPendingIntent(
                    0,
                    PendingIntent.FLAG_UPDATE_CURRENT
            );
    builder.setContentIntent(resultPendingIntent);
    NotificationManager notificationManager =
            (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(1, builder.build());
}
 
开发者ID:VNGIoTLab,项目名称:vbluno_android_ibeacon,代码行数:20,代码来源:BeaconReferenceApplication.java

示例6: showAppNotification

import android.app.TaskStackBuilder; //导入方法依赖的package包/类
private void showAppNotification(){
    mBuilder.setSmallIcon(R.drawable.ic_notification);
    mBuilder.setLargeIcon(mIcon);
        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 application 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);

    startForeground(SERVICE_IDENTIFIER, mBuilder.build());
}
 
开发者ID:SecUSo,项目名称:privacy-friendly-netmonitor,代码行数:23,代码来源:PassiveService.java

示例7: showNotification

import android.app.TaskStackBuilder; //导入方法依赖的package包/类
public void showNotification() {
    NotificationCompat.Builder builder = (NotificationCompat.Builder) new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.ic_favorite_black_24dp)
            .setContentTitle("Test")
            .setContentText("123");
    // 点击通知触发的 Intent
    Intent resulteIntent = new Intent(this, MainActivity.class);
    // 任务栈 Builder
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
    stackBuilder.addParentStack(MainActivity.class);
    stackBuilder.addNextIntent(resulteIntent);
    PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);

    builder.setContentIntent(resultPendingIntent);
    // 构建通知
    Notification notification = builder.build();
    // 通知管理器
    NotificationManager notificationMgr = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    notificationMgr.notify(NOTIFY_ID, notification);
}
 
开发者ID:Codpoe,项目名称:Learn,代码行数:21,代码来源:LearnService.java

示例8: showRemindInfoNotification

import android.app.TaskStackBuilder; //导入方法依赖的package包/类
private void showRemindInfoNotification(Context context){
    NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
            .setContentTitle("LETO Toggl")
            .setContentText("Toggl stopped. Will remind you to start tracking in 30 minutes!")
            .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
            .setVibrate(null)
            .setColor(ContextCompat.getColor(context, R.color.flat_red))
            .setCategory(Notification.CATEGORY_MESSAGE)
            .setPriority(Notification.PRIORITY_HIGH)
            .setShowWhen(true)
            .setAutoCancel(true)
            .setVisibility(Notification.VISIBILITY_PUBLIC)
            .setStyle(new NotificationCompat.BigTextStyle().bigText("Toggl stopped. Will remind you to start tracking in 30 minutes!"))
            .setSmallIcon(R.drawable.ic_stop);
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
    stackBuilder.addNextIntent(new Intent(context, MainActivity.class));
    PendingIntent resultPendingIntent =
            stackBuilder.getPendingIntent(
                    0,
                    PendingIntent.FLAG_UPDATE_CURRENT
            );
    builder.setContentIntent(resultPendingIntent);
    NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(NotificationActionHandler.STOP_ID, builder.build());
}
 
开发者ID:letolab,项目名称:LETO-Toggl_Android,代码行数:26,代码来源:NotificationActionHandler.java

示例9: showSimpleNotification

import android.app.TaskStackBuilder; //导入方法依赖的package包/类
private void showSimpleNotification() {
    NotificationCompat.Builder builder = new NotificationCompat.Builder(getContext())
            .setSmallIcon(android.R.drawable.ic_notification_overlay)
            .setAutoCancel(true)
            .setContentTitle(getString(R.string.normal_notification_title))
            .setContentText(getString(R.string.normal_notification_text))
            .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));

    TaskStackBuilder stackBuilder = TaskStackBuilder.create(getContext());
    stackBuilder.addParentStack(MainActivity.class);

    Intent resultIntent = new Intent(getContext(), MainActivity.class);
    stackBuilder.addNextIntent(resultIntent);

    PendingIntent resultPendingIntent = stackBuilder
            .getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
    builder.setContentIntent(resultPendingIntent);

    NotificationManager notificationManager = (NotificationManager)
            getContext().getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(NOTIFICATION_ID_MAIN_MENU, builder.build());
}
 
开发者ID:google,项目名称:talkback,代码行数:23,代码来源:NotificationTest.java

示例10: setNotification

import android.app.TaskStackBuilder; //导入方法依赖的package包/类
/**
 * Helper to set Notification when the alarm goes off
 */
private void setNotification() {
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mContext);
    mBuilder.setSmallIcon(R.mipmap.ic_bug_report_white_36dp);
    mBuilder.setContentTitle("Found a Tick?");
    mBuilder.setContentText("Click here to make an Observation of encountered Tick!");
    Uri uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    mBuilder.setSound(uri);

    Intent resultIntent = new Intent(mContext, ObservationMasterActivity.class);
    // put the extras in addObservationIntent to perform fragment Transaction efficiently.
    resultIntent.putExtra(UserActivityMasterActivity.KEY_ACTIVITY_ADD_OBS, 1);
    resultIntent.putExtra(UserActivityMasterActivity.KEY_ACTIVITY_ID, ongoingActivityObj.getId());
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(mContext);
    stackBuilder.addParentStack(ObservationMasterActivity.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) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
    // notificationID allows you to update the notification later on.
    mNotificationManager.notify(12345, mBuilder.build());
}
 
开发者ID:pmk2429,项目名称:investickation,代码行数:29,代码来源:ActivityRunningFragment.java

示例11: setNotification

import android.app.TaskStackBuilder; //导入方法依赖的package包/类
private void setNotification() {
    final Intent resultIntent = new Intent(this, MainActivity.class);
    final TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
    stackBuilder.addParentStack(MainActivity.class);
    stackBuilder.addNextIntent(resultIntent);
    final PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);

    mBuilder = new NotificationCompat.Builder(this)
            .setContentText(getString(R.string.notification_bt_on))
            .setContentTitle(getString(R.string.device_hive))
            .setSmallIcon(R.drawable.ic_le_service)
            .setAutoCancel(false)
            .setOngoing(true)
            .setContentIntent(resultPendingIntent);

    mNotificationManager.notify(LE_NOTIFICATION_ID, mBuilder.build());
}
 
开发者ID:devicehive,项目名称:android-ble,代码行数:18,代码来源:BluetoothLeService.java

示例12: sendNotification

import android.app.TaskStackBuilder; //导入方法依赖的package包/类
public static void sendNotification(final Context context,final String postfix,final String message){
	final Notification.Builder mBuilder =
	        new Notification.Builder(context)
	        .setSmallIcon(R.drawable.ic_launcher)
	        .setContentTitle(context.getText(R.string.app_name)+" "+postfix)
	        .setContentText(message);
	// Creates an explicit intent for an Activity in your app
	final Intent resultIntent = new Intent(context, 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 application to the Home screen.
	final TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
	// 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);
	final NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
	if (mNotificationManager!=null) {
           // mId allows you to update the notification later on.
           int mId = 0;
           mNotificationManager.notify(mId, mBuilder.build());

           Analytics.getInstance().logEvent(TAG, "sendNotification", "message");
       }
}
 
开发者ID:videgro,项目名称:Ships,代码行数:30,代码来源:Utils.java

示例13: createSettingsIntent

import android.app.TaskStackBuilder; //导入方法依赖的package包/类
/**
 * Creates an intent to open Fit Notifications settings when notification is clicked.
 */
private PendingIntent createSettingsIntent() {
    // Creates an explicit intent for the SettingsActivity in the app
    Intent settingsIntent = new Intent(this, SettingsActivity.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 the application to
    // the Home screen.
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
    // Adds the back stack for the Intent (but not the Intent itself)
    stackBuilder.addParentStack(SettingsActivity.class);
    // Adds the Intent that starts the Activity to the top of the stack
    stackBuilder.addNextIntent(settingsIntent);
    return stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:18,代码来源:NLService.java

示例14: onReceive

import android.app.TaskStackBuilder; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {

    NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

    //Do some operations, like loading values from a file, and show it in the notification or pass it in the calledActivity
    String loadedString = "This is a string loaded from the Receiver";

    Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

    //Building our custom Notification
    NotificationCompat.Builder mBuilder =
            (NotificationCompat.Builder) new NotificationCompat.Builder(context)
                    .setSmallIcon(R.drawable.ic_flag) //Set icon
                    .setContentTitle("Notification Title")
                    .setContentText("Click to call calledActivity")
                    .setSound(alarmSound)
                    .setColor(Color.argb(0,21,101,192)) //Color your notification
                    .setVibrate(new long[]{300, 300, 300, 300, 300}) //Vibration intensity
                    .setAutoCancel(true);

    //setting activity called clicking on the notification
    Intent resultIntent = new Intent(context, calledActivity.class);
    resultIntent.putExtra(calledActivity.WORD, loadedString);
    resultIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);

    //Building virtual stack, allowing the user to press back to go back to the main activity
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
    stackBuilder.addParentStack(calledActivity.class);
    stackBuilder.addNextIntent(resultIntent);

    PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);

    mBuilder.setContentIntent(resultPendingIntent);
    notificationManager.notify(MainActivity.notifId, mBuilder.build());
}
 
开发者ID:Cesarsk,项目名称:Android-Notifications-Sample,代码行数:37,代码来源:NotificationReceiver.java

示例15: createStreamNotification

import android.app.TaskStackBuilder; //导入方法依赖的package包/类
private Notification createStreamNotification(StreamInfo stream, @Nullable Bitmap image, boolean showViewers, Context context) {
    Intent resultIntent = LiveStreamActivity.createLiveStreamIntent(stream, false, context);

    TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
    stackBuilder.addParentStack(MyStreamsActivity.class);
    stackBuilder.addNextIntent(resultIntent);

    PendingIntent clickIntent = stackBuilder.getPendingIntent(
            stream.getChannelInfo().getDisplayName().hashCode(),
            PendingIntent.FLAG_UPDATE_CURRENT
    );

    NotificationTextData textData = constructStreamNotificationText(stream, context);
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
            .setAutoCancel(false)
            .setContentTitle(textData.getTitle())
            .setContentText(textData.getContent())
            .setGroup(GROUP_KEY)
            .setWhen(stream.getStartedAt())
            .setShowWhen(true)
            .setSmallIcon(R.drawable.ic_notification_icon_refresh)
            .setColor(ContextCompat.getColor(context, R.color.primary))
            .setContentIntent(clickIntent);

    if (image != null) {
        mBuilder.setLargeIcon(image);
    }

    if (showViewers) {
        mBuilder.setSubText(textData.getSubtext());
    }

    return mBuilder.build();
}
 
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:35,代码来源:NotificationReceiver.java


注:本文中的android.app.TaskStackBuilder.getPendingIntent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。