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


Java TaskStackBuilder.create方法代码示例

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


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

示例1: onCreate

import android.support.v4.app.TaskStackBuilder; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    TaskStackBuilder builder = TaskStackBuilder.create(this);
    Intent proxyIntent = getIntent();
    if (!proxyIntent.hasExtra(EXTRA_INTENTS)) {
        finish();
        return;
    }

    for (Parcelable parcelable : proxyIntent.getParcelableArrayExtra(EXTRA_INTENTS)) {
        builder.addNextIntent((Intent) parcelable);
    }

    builder.startActivities();
    finish();
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:19,代码来源:TaskStackBuilderProxyActivity.java

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

示例3: onSupportNavigateUp

import android.support.v4.app.TaskStackBuilder; //导入方法依赖的package包/类
public boolean onSupportNavigateUp() {
    Intent upIntent = getSupportParentActivityIntent();
    if (upIntent == null) {
        return false;
    }
    if (supportShouldUpRecreateTask(upIntent)) {
        TaskStackBuilder b = TaskStackBuilder.create(this);
        onCreateSupportNavigateUpTaskStack(b);
        onPrepareSupportNavigateUpTaskStack(b);
        b.startActivities();
        try {
            ActivityCompat.finishAffinity(this);
        } catch (IllegalStateException e) {
            finish();
        }
    } else {
        supportNavigateUpTo(upIntent);
    }
    return true;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:21,代码来源:AppCompatActivity.java

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

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

示例6: onClick

import android.support.v4.app.TaskStackBuilder; //导入方法依赖的package包/类
@Override
public void onClick(View v) {
    // This ID represents the Home or Up button. In the case of this
    // activity, the Up button is shown. Use NavUtils to allow users
    // to navigate up one level in the application structure. For
    // more details, see the Navigation pattern on Android Design:
    //
    // http://developer.android.com/design/patterns/navigation.html#up-vs-back
    //
    final Intent listIntent = new Intent(this, PostItemListActivity.class);
    if (NavUtils.shouldUpRecreateTask(this, listIntent)) {
        final TaskStackBuilder taskStack = TaskStackBuilder.create(this);
        taskStack.addNextIntent(listIntent);
        taskStack.startActivities();
    } else {
        NavUtils.navigateUpTo(this, listIntent);
    }
}
 
开发者ID:MimiReader,项目名称:mimi-reader,代码行数:19,代码来源:PostItemDetailActivity.java

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

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

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

示例10: updateIntroductionNotification

import android.support.v4.app.TaskStackBuilder; //导入方法依赖的package包/类
@UiThread
private void updateIntroductionNotification() {
	NotificationCompat.Builder b =
			new NotificationCompat.Builder(appContext);
	b.setSmallIcon(R.drawable.notification_introduction);
	b.setColor(ContextCompat.getColor(appContext, R.color.briar_primary));
	b.setContentTitle(appContext.getText(R.string.app_name));
	b.setContentText(appContext.getResources().getQuantityString(
			R.plurals.introduction_notification_text, introductionTotal,
			introductionTotal));
	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 contact list
	Intent i = new Intent(appContext, NavDrawerActivity.class);
	i.putExtra(INTENT_CONTACTS, true);
	i.setFlags(FLAG_ACTIVITY_CLEAR_TOP);
	i.setData(Uri.parse(CONTACT_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_MESSAGE);
		b.setVisibility(VISIBILITY_SECRET);
	}
	Object o = appContext.getSystemService(NOTIFICATION_SERVICE);
	NotificationManager nm = (NotificationManager) o;
	nm.notify(INTRODUCTION_SUCCESS_NOTIFICATION_ID, b.build());
}
 
开发者ID:rafjordao,项目名称:Nird2,代码行数:34,代码来源:AndroidNotificationManagerImpl.java

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

示例12: showNotification

import android.support.v4.app.TaskStackBuilder; //导入方法依赖的package包/类
/**
 * Displays a notification with the location results.
 */
void showNotification() {
    Intent notificationIntent = new Intent(mContext, MainActivity.class);

    // Construct a task stack.
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(mContext);

    // Add the main Activity to the task stack as the parent.
    stackBuilder.addParentStack(MainActivity.class);

    // Push the content Intent onto the stack.
    stackBuilder.addNextIntent(notificationIntent);

    // Get a PendingIntent containing the entire back stack.
    PendingIntent notificationPendingIntent =
            stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);

    Notification.Builder notificationBuilder = new Notification.Builder(mContext,
            PRIMARY_CHANNEL)
            .setContentTitle(getLocationResultTitle())
            .setContentText(getLocationResultText())
            .setSmallIcon(R.mipmap.ic_launcher)
            .setAutoCancel(true)
            .setContentIntent(notificationPendingIntent);

    getNotificationManager().notify(0, notificationBuilder.build());
}
 
开发者ID:googlecodelabs,项目名称:background-location-updates-android-o,代码行数:30,代码来源:LocationResultHelper.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: 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

示例15: showSyncNotification

import android.support.v4.app.TaskStackBuilder; //导入方法依赖的package包/类
private void showSyncNotification() {
    DebugLog.logMethod();
    NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
            .setContentTitle(contentTitle)
            .setContentText(contentText)
            .setWhen(System.currentTimeMillis())
            .setLargeIcon(Utilities.getBitmap(context, largeIconId))
            .setSmallIcon(smallIconId)
            .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
            .setAutoCancel(true);

    TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
    stackBuilder.addNextIntent(new Intent(context, CouponListActivity.class));
    PendingIntent contentPendingIntent = stackBuilder.getPendingIntent(
            0,
            PendingIntent.FLAG_UPDATE_CURRENT
    );
    builder.setContentIntent(contentPendingIntent);

    // Cancel any previously shown notification
    NotificationManagerCompat.from(context).cancel(TAG, SYNC_NOTIFICATION_ID);
    // Show notification
    NotificationManagerCompat.from(context).notify(
            TAG,
            SYNC_NOTIFICATION_ID,
            builder.build()
    );
}
 
开发者ID:darsh2,项目名称:CouponsTracker,代码行数:29,代码来源:CouponsTrackerNotification.java


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