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


Java TaskStackBuilder类代码示例

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


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

示例1: onOptionsItemSelected

import android.support.v4.app.TaskStackBuilder; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        // Respond to the action bar's Up/Home button
        case android.R.id.home:
            Intent upIntent = NavUtils.getParentActivityIntent(this);
            upIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            if (NavUtils.shouldUpRecreateTask(this, upIntent)) {
                // This activity is NOT part of this app's task, so create a new task
                // when navigating up, with a synthesized back stack.
                TaskStackBuilder.create(this)
                        // Add all of this activity's parents to the back stack
                        .addNextIntentWithParentStack(upIntent)
                        // Navigate up to the closest parent
                        .startActivities();
            } else {
                // This activity is part of this app's task, so simply
                // navigate up to the logical parent activity.
                NavUtils.navigateUpTo(this, upIntent);
            }
            return true;
    }
    return super.onOptionsItemSelected(item);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:FeedActivity.java

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

示例3: createViewMessagesPendingIntent

import android.support.v4.app.TaskStackBuilder; //导入依赖的package包/类
public PendingIntent createViewMessagesPendingIntent(Account account, List<MessageReference> messageReferences,
        int notificationId) {

    TaskStackBuilder stack;
    if (account.goToUnreadMessageSearch()) {
        stack = buildUnreadBackStack(account);
    } else {
        String folderId = getFolderIdOfAllMessages(messageReferences);

        if (folderId == null) {
            stack = buildFolderListBackStack(account);
        } else {
            stack = buildMessageListBackStack(account, folderId);
        }
    }

    return stack.getPendingIntent(notificationId, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_ONE_SHOT);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:19,代码来源:NotificationActionCreator.java

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

示例5: startPlacelineScreen

import android.support.v4.app.TaskStackBuilder; //导入依赖的package包/类
private void startPlacelineScreen() {
    CrashlyticsWrapper.setCrashlyticsKeys(this);
    showProgress(false);

    // Clear Existing running trip on Registration Successful
    SharedPreferenceManager.deleteAction(this);
    SharedPreferenceManager.deletePlace(this);

    HyperLog.i(TAG, "User Registration successful: Clearing Active Trip, if any");
    Intent intent = new Intent(Profile.this, Placeline.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    TaskStackBuilder.create(Profile.this)
            .addNextIntentWithParentStack(intent)
            .startActivities();
    finish();
}
 
开发者ID:hypertrack,项目名称:hypertrack-live-android,代码行数:17,代码来源:Profile.java

示例6: startPlacelineScreen

import android.support.v4.app.TaskStackBuilder; //导入依赖的package包/类
private void startPlacelineScreen() {
    CrashlyticsWrapper.setCrashlyticsKeys(this);
    showProgress(false);

    // Clear Existing running trip on Registration Successful
    SharedPreferenceManager.deleteAction(this);
    SharedPreferenceManager.deletePlace(this);

    HyperLog.i(TAG, "User Registration successful: Clearing Active Trip, if any");
    Intent intent = new Intent(Verify.this, Placeline.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    TaskStackBuilder.create(Verify.this)
            .addNextIntentWithParentStack(intent)
            .startActivities();
    finish();
}
 
开发者ID:hypertrack,项目名称:hypertrack-live-android,代码行数:17,代码来源:Verify.java

示例7: handleTrackingDeepLinkError

import android.support.v4.app.TaskStackBuilder; //导入依赖的package包/类
private void handleTrackingDeepLinkError() {
    ActionManager actionManager = ActionManager.getSharedManager(this);
    //Check if there is any existing task to be restored
    if (actionManager.shouldRestoreState()) {
        TaskStackBuilder.create(this)
                .addNextIntentWithParentStack(new Intent(this, Home.class)
                        .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
                .startActivities();
    } else {
        TaskStackBuilder.create(this)
                .addNextIntentWithParentStack(new Intent(this, Placeline.class)
                        .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
                .startActivities();
    }
    finish();
    actionManager = null;
}
 
开发者ID:hypertrack,项目名称:hypertrack-live-android,代码行数:18,代码来源:SplashScreen.java

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

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

示例10: onCreate

import android.support.v4.app.TaskStackBuilder; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    if (sharedPref.getBoolean(SettingsActivity.KEY_COLLECTE_ACTIVER, false)) {
        SharedPreferences.Editor editor = sharedPref.edit();
        editor.putBoolean(SettingsActivity.KEY_COLLECTE_ACTIVER, false);
        editor.commit();
    }

    TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
    stackBuilder.addNextIntent(new Intent(this, MainActivity.class));
    stackBuilder.addParentStack(MainActivity.class);

    stackBuilder.startActivities();
}
 
开发者ID:ANFR-France,项目名称:proto-collecte,代码行数:17,代码来源:StopCollecteActivity.java

示例11: onCreate

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

    // Check if Driver is logged in currently
    String driverId = SharedPreferenceStore.getDriverId(this);
    if (TextUtils.isEmpty(driverId)) {

        // Initiate Driver Login by starting LoginActivity
        TaskStackBuilder.create(SplashScreen.this)
                .addNextIntentWithParentStack(new Intent(SplashScreen.this, LoginActivity.class)
                        .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
                .startActivities();
        finish();
    } else {

        // Start Driver Session by starting MainActivity
        TaskStackBuilder.create(SplashScreen.this)
                .addNextIntentWithParentStack(new Intent(SplashScreen.this, MainActivity.class)
                        .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
                .startActivities();
        finish();
    }
}
 
开发者ID:hypertrack,项目名称:service-visit-example-android,代码行数:26,代码来源:SplashScreen.java

示例12: navigateUpOrBack

import android.support.v4.app.TaskStackBuilder; //导入依赖的package包/类
/**
 * This utility method handles Up navigation intents by searching for a parent activity and
 * navigating there if defined. When using this for an activity make sure to define both the
 * native parentActivity as well as the AppCompat one when supporting API levels less than 16.
 * when the activity has a single parent activity. If the activity doesn't have a single parent
 * activity then don't define one and this method will use back button functionality. If "Up"
 * functionality is still desired for activities without parents then use
 * {@code syntheticParentActivity} to define one dynamically.
 *
 * Note: Up navigation intents are represented by a back arrow in the top left of the Toolbar
 *       in Material Design guidelines.
 *
 * @param currentActivity Activity in use when navigate Up action occurred.
 * @param syntheticParentActivity Parent activity to use when one is not already configured.
 */
public static void navigateUpOrBack(Activity currentActivity,
                                    Class<? extends Activity> syntheticParentActivity) {
    // Retrieve parent activity from AndroidManifest.
    Intent intent = NavUtils.getParentActivityIntent(currentActivity);

    // Synthesize the parent activity when a natural one doesn't exist.
    if (intent == null && syntheticParentActivity != null) {
        try {
            intent = NavUtils.getParentActivityIntent(currentActivity, syntheticParentActivity);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
    }

    if (intent == null) {
        // No parent defined in manifest. This indicates the activity may be used by
        // in multiple flows throughout the app and doesn't have a strict parent. In
        // this case the navigation up button should act in the same manner as the
        // back button. This will result in users being forwarded back to other
        // applications if currentActivity was invoked from another application.
        currentActivity.onBackPressed();
    } else {
        if (NavUtils.shouldUpRecreateTask(currentActivity, intent)) {
            // Need to synthesize a backstack since currentActivity was probably invoked by a
            // different app. The preserves the "Up" functionality within the app according to
            // the activity hierarchy defined in AndroidManifest.xml via parentActivity
            // attributes.
            TaskStackBuilder builder = TaskStackBuilder.create(currentActivity);
            builder.addNextIntentWithParentStack(intent);
            builder.startActivities();
        } else {
            // Navigate normally to the manifest defined "Up" activity.
            NavUtils.navigateUpTo(currentActivity, intent);
        }
    }
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:52,代码来源:BaseActivity.java

示例13: onOptionsItemSelected

import android.support.v4.app.TaskStackBuilder; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == android.R.id.home) {
        Intent upIntent = new Intent(this, MainActivity.class);
        if (NavUtils.shouldUpRecreateTask(this, upIntent)) {
            // This activity is not part of the application's task, so create a new task
            // with a synthesized back stack.
            TaskStackBuilder.from(this)
                    .addNextIntent(upIntent)
                    .startActivities();
            finish();
        } else {
            // This activity is part of the application's task, so simply
            // navigate up to the hierarchical parent activity.
            NavUtils.navigateUpTo(this, upIntent);
        }
        return true;
    } else if (item.getTitle().equals("Settings")) {
        //startActivity(new Intent(this, Settings.class));
        finish();
        // overridePendingTransition(R.anim.hold, R.anim.push_out_to_left);
        return true;
    }
    return super.onOptionsItemSelected(item);
}
 
开发者ID:SalmanTKhan,项目名称:MyAnimeViewer,代码行数:26,代码来源:AnimeDetailsActivity.java

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

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


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