Example usage for android.content Intent FLAG_ACTIVITY_CLEAR_TASK

List of usage examples for android.content Intent FLAG_ACTIVITY_CLEAR_TASK

Introduction

In this page you can find the example usage for android.content Intent FLAG_ACTIVITY_CLEAR_TASK.

Prototype

int FLAG_ACTIVITY_CLEAR_TASK

To view the source code for android.content Intent FLAG_ACTIVITY_CLEAR_TASK.

Click Source Link

Document

If set in an Intent passed to Context#startActivity Context.startActivity() , this flag will cause any existing task that would be associated with the activity to be cleared before the activity is started.

Usage

From source file:com.vantiv.android.gms.samples.wallet.FullWalletConfirmationButtonFragment.java

@Override
public void processFinish(JSONObject output, FullWallet fullWallet) {
    Log.d(TAG, "Txn Response: " + output.toString());

    Intent intent = new Intent(getActivity(), OrderCompleteActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.putExtra(Constants.EXTRA_FULL_WALLET, fullWallet);
    startActivity(intent);/*from w  w  w  .jav a2s.  com*/
}

From source file:com.ruesga.rview.misc.NotificationsHelper.java

private static PendingIntent getViewChangePendingIntent(Context ctx, NotificationEntity entity) {
    Intent intent = new Intent(ctx, ChangeDetailsActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
    intent.putExtra(Constants.EXTRA_ACCOUNT_HASH, entity.mAccountId);
    intent.putExtra(Constants.EXTRA_NOTIFICATION_GROUP_ID, entity.mGroupId);
    intent.putExtra(Constants.EXTRA_CHANGE_ID, entity.mNotification.change);
    intent.putExtra(Constants.EXTRA_LEGACY_CHANGE_ID, entity.mNotification.legacyChangeId);
    intent.putExtra(Constants.EXTRA_HAS_PARENT, false);
    intent.putExtra(Constants.EXTRA_FORCE_SINGLE_PANEL, true);

    return PendingIntent.getActivity(ctx, entity.mGroupId, intent, PendingIntent.FLAG_UPDATE_CURRENT);
}

From source file:org.wso2.emm.agent.services.operationMgt.OperationManager.java

/**
 * Ring the device.//from   w  w  w . j a v a 2  s.  co  m
 *
 * @param operation - Operation object.
 */
public void ringDevice(org.wso2.emm.agent.beans.Operation operation) {
    operation.setStatus(resources.getString(R.string.operation_value_completed));
    resultBuilder.build(operation);
    Intent intent = new Intent(context, AlertActivity.class);
    intent.putExtra(resources.getString(R.string.intent_extra_type),
            resources.getString(R.string.intent_extra_ring));
    intent.putExtra(resources.getString(R.string.intent_extra_message),
            resources.getString(R.string.intent_extra_stop_ringing));
    intent.setFlags(
            Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);

    if (Constants.DEBUG_MODE_ENABLED) {
        Log.d(TAG, "Ringing is activated on the device");
    }
}

From source file:com.android.settingslib.drawer.SettingsDrawerActivity.java

/**
 * xinsi/*from  w  w w.j a  v a2  s  .  com*/
 *  Tile
 */
public boolean openTile(Tile tile) {
    closeDrawer();
    if (tile == null) {
        startActivity(new Intent(Settings.ACTION_SETTINGS).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK));
        return true;
    }
    try {
        updateUserHandlesIfNeeded(tile);
        int numUserHandles = tile.userHandle.size();
        if (numUserHandles > 1) {
            ProfileSelectDialog.show(getFragmentManager(), tile);
            return false;
        } else if (numUserHandles == 1) {
            // Show menu on top level items.
            tile.intent.putExtra(EXTRA_SHOW_MENU, true);
            tile.intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
            startActivityAsUser(tile.intent, tile.userHandle.get(0));
        } else {
            // Show menu on top level items.
            tile.intent.putExtra(EXTRA_SHOW_MENU, true);
            tile.intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
            startActivity(tile.intent);
        }
    } catch (ActivityNotFoundException e) {
        Log.w(TAG, "Couldn't find tile " + tile.intent, e);
    }
    return true;
}

From source file:id.zelory.codepolitan.ui.ReadActivity.java

@Override
public void onBackPressed() {
    removeReadArticle();//from  w  ww  . ja  va 2s.  c  o m

    if (type == TYPE_FROM_NOTIF) {
        Intent intent = new Intent(this, MainActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
        startActivity(intent);
        finish();
    } else {
        super.onBackPressed();
    }
}

From source file:cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.data.receiver.NotificationHelper.java

/**
 * Needs the builder that contains non-note specific values.
 *
 *//*www. ja v a 2 s.c  om*/
private static void notifyBigText(final Context context, final NotificationManager notificationManager,
        final NotificationCompat.Builder builder,
        final cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.data.model.sql.Notification note) {
    final Intent delIntent = new Intent(Intent.ACTION_DELETE, note.getUri());
    if (note.repeats != 0) {
        delIntent.setAction(ACTION_RESCHEDULE);
    }
    // Add extra so we don't delete all
    // if (note.time != null) {
    // delIntent.putExtra(ARG_MAX_TIME, note.time);
    // }
    delIntent.putExtra(ARG_TASKID, note.taskID);
    // Delete it on clear
    PendingIntent deleteIntent = PendingIntent.getBroadcast(context, 0, delIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    // Open intent
    final Intent openIntent = new Intent(Intent.ACTION_VIEW, Task.getUri(note.taskID));
    // Should create a new instance to avoid fragment problems
    openIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);

    // Delete intent on non-location repeats
    // Opening the note should delete/reschedule the notification
    openIntent.putExtra(NOTIFICATION_DELETE_ARG, note._id);

    // Opening always cancels the notification though
    openIntent.putExtra(NOTIFICATION_CANCEL_ARG, note._id);

    // Open note on click
    PendingIntent clickIntent = PendingIntent.getActivity(context, 0, openIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    // Action to complete
    PendingIntent completeIntent = PendingIntent.getBroadcast(context, 0,
            new Intent(ACTION_COMPLETE, note.getUri()).putExtra(ARG_TASKID, note.taskID),
            PendingIntent.FLAG_UPDATE_CURRENT);

    // Action to snooze
    PendingIntent snoozeIntent = PendingIntent.getBroadcast(context, 0,
            new Intent(ACTION_SNOOZE, note.getUri()).putExtra(ARG_TASKID, note.taskID),
            PendingIntent.FLAG_UPDATE_CURRENT);

    // Build notification
    builder.setContentTitle(note.taskTitle).setContentText(note.taskNote).setContentIntent(clickIntent)
            .setStyle(new NotificationCompat.BigTextStyle().bigText(note.taskNote));

    // Delete intent on non-location repeats
    builder.setDeleteIntent(deleteIntent);

    // Snooze button only on time non-repeating
    if (note.time != null && note.repeats == 0) {
        builder.addAction(R.drawable.ic_alarm_24dp_white, context.getText(R.string.snooze), snoozeIntent);
    }
    // Complete button only on non-repeating, both time and location
    if (note.repeats == 0) {
        builder.addAction(R.drawable.ic_check_24dp_white, context.getText(R.string.completed), completeIntent);
    }

    final Notification noti = builder.build();

    notificationManager.notify((int) note._id, noti);
}

From source file:samples.piggate.com.piggateCompleteExample.Activity_Logged.java

public void logout() {

    if (checkInternetConnection() == true) { //If the internet connection is working

        loadingDialog = ProgressDialog.show(this, "Singing Out", "Wait a few seconds", false);

        //Request a session close for the logged user
        _piggate.RequestCloseSession().setListenerRequest(new Piggate.PiggateCallBack() {

            //Method onComplete for JSONObject
            @Override/* w w  w .j a  va  2 s .  co m*/
            public void onComplete(int statusCode, Header[] headers, String msg, JSONObject data) {

                loadingDialog.dismiss();
                Service_Notify.logout = true;

                //Go back to the main activity
                Intent slideactivity = new Intent(Activity_Logged.this, Activity_Main.class);
                slideactivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
                Bundle bndlanimation = ActivityOptions
                        .makeCustomAnimation(getApplicationContext(), R.anim.slidefromleft, R.anim.slidetoright)
                        .toBundle();
                startActivity(slideactivity, bndlanimation);
            }

            //Method onError for JSONObject
            @Override
            public void onError(int statusCode, Header[] headers, String msg, JSONObject data) {
                Service_Notify.logout = false;
                loadingDialog.dismiss();
                errorDialog.show();
                _piggate.reload();
            }

            //Method onComplete for JSONArray
            @Override
            public void onComplete(int statusCode, Header[] headers, String msg, JSONArray data) {
                //Unused
            }

            //Method onError for JSONArray
            @Override
            public void onError(int statusCode, Header[] headers, String msg, JSONArray data) {
                //Unused
            }
        }).exec();

    } else { //If internet conexion is not working displays an error message
        networkErrorDialog.show();
    }
}

From source file:com.ruesga.rview.misc.NotificationsHelper.java

private static PendingIntent getViewAccountChangesPendingIntent(Context ctx, Account account,
        int notificationId) {
    Intent intent = new Intent(ctx, NotificationsActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
    intent.putExtra(Constants.EXTRA_ACCOUNT_HASH, account.getAccountHash());
    intent.putExtra(Constants.EXTRA_HAS_PARENT, false);

    return PendingIntent.getActivity(ctx, notificationId, intent, PendingIntent.FLAG_UPDATE_CURRENT);
}

From source file:cl.iluminadoschile.pako.floatingdiv.CustomOverlayService.java

@Override
protected Notification foregroundNotification(int notificationId) {
    Notification notification;//from   ww  w .  j  av  a2s . c  o  m

    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
            && activation_method.equals(Constants.SETTINGS.ACTIVATION_METHOD_MANUAL)) {
        Intent settingsIntent = new Intent(Intent.ACTION_MAIN);
        settingsIntent.setClassName(Constants.ACTION.prefix, Constants.ACTION.prefix + ".SettingsActivity");
        settingsIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, settingsIntent, 0);

        Intent startFgIntent = new Intent(this, CustomOverlayService.class);
        startFgIntent.setAction(Constants.ACTION.STARTFOREGROUND_ACTION);
        PendingIntent pstartFgIntent = PendingIntent.getService(this, 0, startFgIntent, 0);

        Intent pauseFgIntent = new Intent(this, CustomOverlayService.class);
        pauseFgIntent.setAction(Constants.ACTION.PAUSEFOREGROUND_ACTION);
        PendingIntent ppauseFgIntent = PendingIntent.getService(this, 0, pauseFgIntent, 0);

        Intent stopFgIntent = new Intent(this, CustomOverlayService.class);
        stopFgIntent.setAction(Constants.ACTION.STOPFOREGROUND_ACTION);
        PendingIntent pstopFgIntent = PendingIntent.getService(this, 0, stopFgIntent, 0);

        Bitmap icon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);

        notification = new NotificationCompat.Builder(this)
                .setContentTitle(getString(R.string.title_notification))
                .setTicker(getString(R.string.title_notification))
                .setContentText(getString(R.string.message_notification)).setSmallIcon(R.drawable.ic_launcher)
                .setLargeIcon(Bitmap.createScaledBitmap(icon, 128, 128, false)).setContentIntent(pendingIntent)
                .setOngoing(true).addAction(android.R.drawable.ic_media_play, "Start", pstartFgIntent)
                .addAction(android.R.drawable.ic_media_pause, "Pause", ppauseFgIntent)
                .addAction(android.R.drawable.ic_delete, "Stop", pstopFgIntent).build();

    } else {
        notification = new Notification(R.drawable.ic_launcher, getString(R.string.title_notification),
                System.currentTimeMillis());

        notification.flags = notification.flags | Notification.FLAG_ONGOING_EVENT
                | Notification.FLAG_ONLY_ALERT_ONCE;

        notification.setLatestEventInfo(this, getString(R.string.title_notification),
                getString(R.string.message_notification_manual), notificationIntent());
    }
    return notification;
}