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


Java TaskStackBuilder.addNextIntent方法代码示例

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


在下文中一共展示了TaskStackBuilder.addNextIntent方法的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: 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

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

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

示例5: sendNotification

import android.app.TaskStackBuilder; //导入方法依赖的package包/类
private void sendNotification() {
    NotificationCompat.Builder builder =
            new NotificationCompat.Builder(this)
                    .setContentTitle(getString(R.string.beacon_notification_title))
                    .setContentText(getString(R.string.beacon_notification_content))
                    .setSmallIcon(R.drawable.ic_mycroft);

    TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
    stackBuilder.addNextIntent(new Intent(this, BeaconActivity.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:MycroftAI,项目名称:Mycroft-Android,代码行数:20,代码来源:MycroftApplication.java

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

示例7: fallback

import android.app.TaskStackBuilder; //导入方法依赖的package包/类
private void fallback(Draft draft, String error) {
	draft.createAt = System.currentTimeMillis();
	getContentResolver().insert(CatnutProvider.parse(Draft.MULTIPLE), Draft.METADATA.convert(draft));
	mBuilder.setContentTitle(getString(R.string.post_fail))
			.setContentText(error)
			.setTicker(getText(R.string.post_fail))
			.setProgress(0, 0, false);

	// 添加fallback跳转
	Intent resultIntent = SingleFragmentActivity.getIntent(this, SingleFragmentActivity.DRAFT);

	TaskStackBuilder taskStackBuilder = TaskStackBuilder.create(this);
	taskStackBuilder.addParentStack(SingleFragmentActivity.class);
	taskStackBuilder.addNextIntent(resultIntent);
	PendingIntent resultPendingIntent =
			taskStackBuilder.getPendingIntent(
					ID,
					PendingIntent.FLAG_UPDATE_CURRENT
			);
	mBuilder.setContentIntent(resultPendingIntent)
			.setAutoCancel(true);
	mNotifyManager.notify(ID, mBuilder.build());
}
 
开发者ID:missmisslonely,项目名称:fakeweibo,代码行数:24,代码来源:ComposeTweetService.java

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

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

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

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

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

示例13: startData

import android.app.TaskStackBuilder; //导入方法依赖的package包/类
void startData(){
        try {
            setMobileDataEnabled(this.getApplicationContext(), true);
        }
        catch(Exception e){
            //    Toast.makeText(this,e.toString(),Toast.LENGTH_SHORT).show();
            NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);

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

            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,代码行数:29,代码来源:digiPune.java

示例14: stopData

import android.app.TaskStackBuilder; //导入方法依赖的package包/类
void stopData()
    {
        try {
            setMobileDataEnabled(this.getApplicationContext(), false);
        }
        catch(Exception e){
            // Toast.makeText(this,e.toString(),Toast.LENGTH_SHORT).show();
            NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);

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

            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,代码行数:30,代码来源:digiPune.java

示例15: setMobileDataEnabled

import android.app.TaskStackBuilder; //导入方法依赖的package包/类
private void setMobileDataEnabled(Context context, boolean enabled) throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        final ConnectivityManager conman = (ConnectivityManager)  context.getSystemService(Context.CONNECTIVITY_SERVICE);
        final Class conmanClass = Class.forName(conman.getClass().getName());
        final Field connectivityManagerField = conmanClass.getDeclaredField("mService");
        connectivityManagerField.setAccessible(true);
        final Object connectivityManager = connectivityManagerField.get(conman);
        final Class connectivityManagerClass =  Class.forName(connectivityManager.getClass().getName());
        final Method setMobileDataEnabledMethod = connectivityManagerClass.getDeclaredMethod("setMobileDataEnabled", Boolean.TYPE);
        setMobileDataEnabledMethod.setAccessible(true);

        try{
            setMobileDataEnabledMethod.invoke(connectivityManager, enabled);
        }

        catch(Exception e){
            //Toast.makeText(this,e.toString(),Toast.LENGTH_SHORT).show();
            NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);

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

            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,代码行数:39,代码来源:digiPune.java


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