Example usage for android.content Intent FLAG_ACTIVITY_NO_HISTORY

List of usage examples for android.content Intent FLAG_ACTIVITY_NO_HISTORY

Introduction

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

Prototype

int FLAG_ACTIVITY_NO_HISTORY

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

Click Source Link

Document

If set, the new activity is not kept in the history stack.

Usage

From source file:com.wifi.brainbreaker.mydemo.spydroid.ui.AboutFragment.java

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.about, container, false);

    mButtonVisit = (Button) rootView.findViewById(R.id.visit);
    mButtonRate = (Button) rootView.findViewById(R.id.rate);
    mButtonLike = (Button) rootView.findViewById(R.id.like);

    mButtonVisit.setOnClickListener(new OnClickListener() {
        @Override//from w ww.  j a va  2  s .  com
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_VIEW,
                    Uri.parse("https://code.google.com/p/spydroid-ipcamera/"));
            intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
            startActivity(intent);
        }
    });

    mButtonRate.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            String appPackageName = SpydroidApplication.getInstance().getApplicationContext().getPackageName();
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName));
            intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
            startActivity(intent);
        }
    });

    mButtonLike.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_VIEW,
                    Uri.parse("http://www.facebook.com/spydroidipcamera"));
            intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
            startActivity(intent);
        }
    });

    return rootView;
}

From source file:tm.android.chronos.activity.Chronos.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.chronos);/* ww  w  .ja  va  2s.c  o  m*/
    Toolbar toolbar = findViewById(R.id.chronos_toolbar);
    setSupportActionBar(toolbar);
    // don't forget this for i18n support from component without android context.
    if (Units.hasNoResources())
        Units.setResources(getResources());

    String directCall = getIntent().getStringExtra(DIRECT_CALL);
    if (directCall != null && !directCall.equals("NONE")) {
        if (directCall.equals(TimerActivity.class.getName())) {
            onClick(findViewById(R.id.btn_timerActivity));
        } else if (directCall.equals(AlarmResultActivity.class.getName())) {
            Intent intent = new Intent(getBaseContext(), AlarmResultActivity.class);
            intent.putExtra("AlarmId", getIntent().getLongExtra("AlarmId", -1));
            intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
            startActivity(intent);
        }

    } else {
        checkPermission();
        if (read_write_ext_storage)
            CommonMediaPlayer.build(this);

        checkZenModeAccess();
    }

}

From source file:com.jbirdvegas.mgerrit.AOKPChangelog.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    // Respond to the action bar's Up/Home button
    case android.R.id.home:
        NavUtils.navigateUpFromSameTask(this);
        return true;
    case R.id.menu_save:
        Intent intent = new Intent(this, PrefsActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
        startActivity(intent);/*from w  ww  . j  a v a2s.  c o  m*/
        return true;
    case R.id.menu_search:
        // Toggle the visibility of the searchview
        mSearchView.toggleVisibility();
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.codebutler.farebot.activities.MainActivity.java

@Override
protected void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    setContentView(R.layout.activity_main);

    ActionBar actionBar = getActionBar();
    actionBar.setHomeButtonEnabled(false);

    mDataCache = new HashMap<String, TransitIdentity>();

    registerForContextMenu(getListView());

    mNfcAdapter = NfcAdapter.getDefaultAdapter(this);

    Intent intent = new Intent(this, ReadingTagActivity.class);
    intent.addFlags(/* w w w.  j a  v a  2 s.  c o  m*/
            Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_HISTORY);
    mPendingIntent = PendingIntent.getActivity(this, 0, intent, 0);

    mTechLists = new String[][] { new String[] { IsoDep.class.getName() },
            new String[] { MifareClassic.class.getName() }, new String[] { MifareUltralight.class.getName() },
            new String[] { NfcF.class.getName() } };

    setListAdapter(new CardsAdapter());
    getLoaderManager().initLoader(0, null, this);
}

From source file:com.kasoft.pushnot.GcmIntentService.java

private void sendNotification(String msg, String title, String form) {
    mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);

    Intent appMainIntent = new Intent(getApplicationContext(), MainActivity.class);
    appMainIntent.putExtra("title", title);
    appMainIntent.putExtra("form", form);
    //appMainIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
    appMainIntent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);

    PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, appMainIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.ic_stat_gcm).setContentTitle(title)
            .setStyle(new NotificationCompat.BigTextStyle().bigText(form)).setContentText(form);
    mBuilder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
    mBuilder.setContentIntent(contentIntent);
    mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
}

From source file:ar.org.fsadosky.iptablesmanager.activity.MainActivity.java

private void goToGooglePlay() {
    Uri uri = Uri.parse("market://details?id=" + getPackageName());
    Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
    // To count with Play market backstack, After pressing back button,
    // to taken back to our application, we need to add following flags to intent.
    goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
            | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
    try {/*from  w  w w  . j a v a2s .  c  om*/
        startActivity(goToMarket);
    } catch (ActivityNotFoundException e) {
        startActivity(new Intent(Intent.ACTION_VIEW,
                Uri.parse("http://play.google.com/store/apps/details?id=" + getPackageName())));
    }
}

From source file:de.appplant.cordova.plugin.notification.NotificationBuilder.java

/**
 * Adds an onclick handler to the notification
 *//* w  w w  . ja v a2s  .c  o m*/
private Builder setClickEvent(Builder notification) {
    Intent intent = new Intent(context, receiverActivity).putExtra(OPTIONS, options.getJSONObject().toString())
            .setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);

    int requestCode = new Random().nextInt();

    PendingIntent contentIntent = PendingIntent.getActivity(context, requestCode, intent,
            PendingIntent.FLAG_CANCEL_CURRENT);

    return notification.setContentIntent(contentIntent);
}

From source file:com.tomdignan.jiffymonitor.MonitorActivity.java

/** {@inheritDoc} */
@Override/*w  w w . java2 s  . c  o m*/
public void onCreate(Bundle savedInstanceState) {
    this.analytics.create(this, TAG);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_resource_monitor_layout);

    this.fragmentManager = getSupportFragmentManager();
    this.updateResourcesRunnable = new UpdateResourcesRunnable();

    this.resourceMonitor = (ResourceMonitorFragment) this.fragmentManager.findFragmentByTag(FRAGMENT_MONITOR);

    if (this.resourceMonitor == null) {
        try {
            this.resourceMonitor = new ResourceMonitorFragment();
        } catch (FileNotFoundException e) {
            Intent intent = new Intent(this, ErrorHandlerActivity.class);
            intent.putExtra(ErrorHandlerActivity.EXTRA_MESSAGE,
                    "This app requires a system file that was not found on your device. "
                            + "For the technical, that file is the Linux /proc/stat file.");
            intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
            startActivity(intent);
            return;
        }
    }

    this.resourceMonitor.setRetainInstance(true);
    this.fragmentManager.beginTransaction().add(this.resourceMonitor, FRAGMENT_MONITOR).commit();
    this.resourceMonitor.setOnResourcesReceivedListener(this);
}

From source file:com.fn.reunion.app.xmpp.Notifier.java

public void notify(String notificationId, String apiKey, String title, String message, String uri) {
    Log.d(LOGTAG, "notify()...");

    Log.d(LOGTAG, "notificationId=" + notificationId);
    Log.d(LOGTAG, "notificationApiKey=" + apiKey);
    Log.d(LOGTAG, "notificationTitle=" + title);
    Log.d(LOGTAG, "notificationMessage=" + message);
    Log.d(LOGTAG, "notificationUri=" + uri);

    if (isNotificationEnabled()) {
        // Show the toast
        if (isNotificationToastEnabled()) {
            Toast.makeText(context, message, Toast.LENGTH_LONG).show();
        }/*from   w  w  w  .  j av  a  2 s .  co m*/

        Notification notification = new Notification();
        notification.icon = getNotificationIcon();
        notification.defaults = Notification.DEFAULT_LIGHTS;

        if (isNotificationSoundEnabled()) {
            notification.defaults |= Notification.DEFAULT_SOUND;
        }

        if (isNotificationVibrateEnabled()) {
            notification.defaults |= Notification.DEFAULT_VIBRATE;
        }

        notification.flags |= Notification.FLAG_AUTO_CANCEL;
        notification.when = System.currentTimeMillis();
        notification.tickerText = message;

        Intent intent = new Intent(context, NotificationDetailsActivity.class);
        intent.putExtra(Constants.NOTIFICATION_ID, notificationId);
        intent.putExtra(Constants.NOTIFICATION_API_KEY, apiKey);
        intent.putExtra(Constants.NOTIFICATION_TITLE, title);
        intent.putExtra(Constants.NOTIFICATION_MESSAGE, message);
        intent.putExtra(Constants.NOTIFICATION_URI, uri);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
        intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
        intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

        PendingIntent contentIntent = PendingIntent.getActivity(context, 0, intent,
                PendingIntent.FLAG_UPDATE_CURRENT);

        /*      notification.setLatestEventInfo(context, notficationMessage , message , contentIntent);
              notificationManager.notify(Consts.NOTIFICATION_ID, notification);*/

        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
                .setSmallIcon(getNotificationIcon()).setContentTitle("").setContentText("");

        Notification n = mBuilder.setContentIntent(contentIntent).setSmallIcon(getNotificationIcon())
                .setTicker("").setWhen(System.currentTimeMillis()).setAutoCancel(true).setContentTitle(title)
                .setStyle(new NotificationCompat.BigTextStyle().bigText(message.replaceAll("[\t\n\r]", "\n")))
                .setContentText(message).build();

        if (isNotificationSoundEnabled()) {
            n.defaults |= Notification.DEFAULT_SOUND;
        }

        if (isNotificationVibrateEnabled()) {
            n.defaults |= Notification.DEFAULT_VIBRATE;
        }
        notificationManager.notify(Consts.NOTIFICATION_ID, n);
        // Notification
    } else {
        Log.w(LOGTAG, "Notificaitons disabled.");
    }
}

From source file:com.vixir.finalproject.perfectday.fragment.MoreInfoFragment.java

@OnClick(R.id.rate_the_app)
public void onClickRateTheApp() {
    Uri uri = Uri.parse("market://details?id=" + getContext().getPackageName());
    Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
    goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_NEW_DOCUMENT
            | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
    try {//from w  ww.  jav a2  s  .co  m
        startActivity(goToMarket);
    } catch (ActivityNotFoundException e) {
        startActivity(new Intent(Intent.ACTION_VIEW,
                Uri.parse("http://play.google.com/store/apps/details?id=" + getContext().getPackageName())));
    }
}