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:ca.six.unittestapp.todo.statistics.StatisticsActivity.java

private void setupDrawerContent(NavigationView navigationView) {
    navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
        @Override//from w  ww  . j a va2 s .  c  o m
        public boolean onNavigationItemSelected(MenuItem menuItem) {
            switch (menuItem.getItemId()) {
            case R.id.list_navigation_menu_item:
                Intent intent = new Intent(StatisticsActivity.this, TasksActivity.class);
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
                startActivity(intent);
                break;
            case R.id.statistics_navigation_menu_item:
                // Do nothing, we're already on that screen
                break;
            default:
                break;
            }
            // Close the navigation drawer when an item is selected.
            menuItem.setChecked(true);
            mDrawerLayout.closeDrawers();
            return true;
        }
    });
}

From source file:com.mobilewrapper.base.gcm.MyGcmListenerService.java

/**
 * Create and show a simple notification containing the received GCM message.
 *
 * @param message GCM message received.//from w  ww  .  j a va2s  .  com
 */
private void sendNotification(PushMessage message) {
    Intent intent = new Intent(this, SplashActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);

    intent.putExtra(WrapperApplication.EXTRA_SERIAL_PUSHMSG, message);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
            PendingIntent.FLAG_ONE_SHOT);

    NotificationCompat.Style style = null;
    if (message.getThumb() == null || message.getThumb().equals("")) {
        style = new NotificationCompat.BigTextStyle().bigText(Html.fromHtml(message.getDescription()));
    } else {
        Bitmap remote_picture = null;
        try {
            remote_picture = BitmapFactory.decodeStream((InputStream) new URL(message.getThumb()).getContent());
        } catch (IOException e) {

        }
        style = new NotificationCompat.BigPictureStyle().bigPicture(remote_picture)
                .setSummaryText(Html.fromHtml(message.getDescription()));
    }

    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.ic_stat_ic_notification)
            .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher))
            .setTicker(message.getTitle()).setContentTitle(message.getTitle())
            .setContentText(message.getDescription()).setAutoCancel(true).setSound(defaultSoundUri)
            .setStyle(style).setContentIntent(pendingIntent);

    if (style instanceof NotificationCompat.BigPictureStyle) {
        notificationBuilder.setContentText(getString(R.string.notification_bigPictureContentText));
    }

    NotificationManager notificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);

    notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
}

From source file:org.akvo.caddisfly.ui.MainActivity.java

/**
 * Navigate to the survey//  ww w.j  av a 2s.com
 */
@OnClick(R.id.buttonSurvey)
void navigateToSurvey() {
    Intent intent = getPackageManager().getLaunchIntentForPackage(AppConfig.FLOW_SURVEY_PACKAGE_NAME);
    if (intent == null) {
        alertDependantAppNotFound();
    } else {

        finishRunnable = new Runnable() {
            @Override
            public void run() {
                finish();
            }
        };

        finishOnSurveyOpenedHandler.postDelayed(finishRunnable, AUTO_FINISH_DELAY_MILLIS);

        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
        startActivity(intent);
    }
}

From source file:com.sukenda.todoapp.module.task.statistics.StatisticsActivity.java

private void setupDrawerContent(NavigationView navigationView) {
    navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
        @Override//from   w  w w .j a  va 2  s.c o  m
        public boolean onNavigationItemSelected(MenuItem menuItem) {
            switch (menuItem.getItemId()) {
            case R.id.list_navigation_menu_item:
                Intent intent = new Intent(StatisticsActivity.this, TasksActivity.class);
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
                    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
                }

                startActivity(intent);
                break;
            case R.id.statistics_navigation_menu_item:
                // Do nothing, we're already on that screen
                break;
            default:
                break;
            }
            // Close the navigation drawer when an item is selected.
            menuItem.setChecked(true);
            mDrawerLayout.closeDrawers();
            return true;
        }
    });
}

From source file:id.satusatudua.sigap.service.EmergencyService.java

@Override
public void onCaseCreated(String caseId) {
    Intent intent = new Intent(this, EmergencyActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
    startActivity(intent);//from   w  ww.j  a v a2s .c  om
}

From source file:edu.Groove9.TunesMaster.statistics.StatisticsActivity.java

private void setupDrawerContent(NavigationView navigationView) {
    navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
        @Override// w w w  . ja  v a 2  s .  com
        public boolean onNavigationItemSelected(MenuItem menuItem) {
            switch (menuItem.getItemId()) {
            case R.id.list_navigation_menu_item:
                Intent intent = new Intent(StatisticsActivity.this, PlaylistActivity.class);
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
                startActivity(intent);
                break;
            case R.id.statistics_navigation_menu_item:
                // Do nothing, we're already on that screen
                break;
            default:
                break;
            }
            // Close the navigation drawer when an item is selected.
            menuItem.setChecked(true);
            mDrawerLayout.closeDrawers();
            return true;
        }
    });
}

From source file:org.trakhound.www.trakhound.device_list.GetDevices.java

@Override
protected void onPostExecute(ListItem[] listItems) {

    MyApplication.Devices = null;/*  w w  w. j a v a  2s  .c o m*/
    MyApplication.ListItems = null;

    MyApplication.ListItems = listItems;

    if (deviceList != null) {

        deviceList.addDevices();
        deviceList.hideLoading();

    } else {

        if (listItems == null) {

            UserManagement.clearRememberToken();
            UserManagement.clearRememberUsername();

            if (context != null)
                context.startActivity(new Intent(context, MainActivity.class));

        } else {

            Intent deviceListIntent = new Intent(context, DeviceList.class);
            deviceListIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK
                    | Intent.FLAG_ACTIVITY_NEW_TASK);

            // Open the Device List Page
            context.startActivity(deviceListIntent);
        }
    }
}

From source file:com.zyascend.RecompileToDo.view.statisticstasks.StatisticsActivity.java

private void setupDrawerContent(NavigationView navigationView) {
    navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
        @Override/*from ww w.  j ava2s. c om*/
        public boolean onNavigationItemSelected(MenuItem item) {
            switch (item.getItemId()) {
            case R.id.list_navigation_menu_item:
                Intent intent = new Intent(StatisticsActivity.this, TasksActivity.class);
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
                startActivity(intent);
                break;
            default:
                break;
            }
            item.setChecked(true);
            mDrawerLayout.closeDrawers();
            return true;
        }
    });
}

From source file:mobisocial.musubi.ui.NearbyActivity.java

public void goHome(Context context) {
    final Intent intent = new Intent(context, FeedListActivity.class);
    if (Build.VERSION.SDK_INT < 11)
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    else/* ww  w .j  av  a2  s. c  o  m*/
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
}

From source file:com.univ.chat.gcm.MyGcmPushReceiver.java

private void showNotificationMessage(Context context, String title, User user, Message message, Intent intent) {
    notificationUtils = new NotificationUtils(context);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
    notificationUtils.showNotificationMessage(title, user, message, intent);
}