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


Java TaskStackBuilder.create方法代码示例

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


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

import android.app.TaskStackBuilder; //导入方法依赖的package包/类
private void showNotification() {
    // 创建通知栏
    Notification.Builder mBuilder = new Notification.Builder(this)
            .setSmallIcon(R.drawable.img_tm)
            .setContentTitle("标题")
            .setContentText("文本");
    // 点击跳转到Activity
    Intent intent = new Intent(this, MainActivity.class);
    // 创建任务栈
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
    stackBuilder.addParentStack(MainActivity.class);
    stackBuilder.addNextIntent(intent);
    PendingIntent pendingIntent = stackBuilder.getPendingIntent(0,PendingIntent.FLAG_UPDATE_CURRENT);
    // 设置跳转
    mBuilder.setContentIntent(pendingIntent);

    // 获取通知服务
    NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    // 构建通知
    Notification notification = mBuilder.build();
    // 显示通知
    nm.notify(0,notification);

    // 启动前台服务
    startForeground(0,notification);
}
 
开发者ID:sdwfqin,项目名称:AndroidSamples,代码行数:27,代码来源:StageService.java

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

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

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

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

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

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

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


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