List of usage examples for android.content Intent FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
To view the source code for android.content Intent FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET.
Click Source Link
From source file:com.charabia.SmsViewActivity.java
@Override public void onResume() { super.onResume(); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); prefPhoneNumber = prefs.getString(PreferencesActivity.PHONE_NUMBER, null); if (prefPhoneNumber == null || prefPhoneNumber.length() <= 0) { Intent intent;//from ww w .j a v a2 s .c om intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); intent.setClassName(this, PreferencesActivity.class.getName()); startActivity(intent); intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); intent.setClassName(this, WebViewActivity.class.getName()); intent.setData(Uri.parse(WebViewActivity.getBaseUrl(this, "/help", "enter_phone_number.html"))); startActivity(intent); //Attempt to retrieve old keys android.content.ContentResolver cr = getContentResolver(); android.database.Cursor cursor = cr.query(Data.CONTENT_URI, new String[] { Data._ID, Tools.PHONE, Tools.KEY }, Data.MIMETYPE + "=?", new String[] { Tools.CONTENT_ITEM_TYPE }, null); while (cursor.moveToNext()) { try { tools.updateOrCreateContactKey(cursor.getString(cursor.getColumnIndex(Tools.PHONE)), Base64.decode(cursor.getString(cursor.getColumnIndex(Tools.KEY)), Base64.DEFAULT), false); cr.delete(ContentUris.withAppendedId(Data.CONTENT_URI, cursor.getLong(cursor.getColumnIndex(Data._ID))), null, null); } catch (NoContactException e) { e.printStackTrace(); Toast.makeText(this, "No contact for " + cursor.getColumnIndex(Tools.PHONE), Toast.LENGTH_SHORT) .show(); } } } }
From source file:com.ubuntuone.android.files.fragment.SignInFragment.java
@SuppressWarnings("unused") private void showSignUpInBrowser() { final Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(Constants.U1_SIGNUP_URL)); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); startActivity(intent);/*from w w w. ja va 2 s .c om*/ }
From source file:com.ruesga.rview.misc.ActivityHelper.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @SuppressWarnings("deprecation") public static void share(Context ctx, String action, String title, String text) { try {// w ww. j ava 2 s. co m Intent intent = new Intent(android.content.Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_SUBJECT, title); intent.putExtra(Intent.EXTRA_TEXT, text); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT); } else { intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); } ctx.startActivity(Intent.createChooser(intent, action)); } catch (ActivityNotFoundException ex) { // Fallback to default browser String msg = ctx.getString(R.string.exception_cannot_share_link); Toast.makeText(ctx, msg, Toast.LENGTH_SHORT).show(); } }
From source file:com.dustinmreed.openwifi.DetailFragment.java
private Intent createShareForecastIntent() { Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_TEXT, mWiFiLocation + "\n" + siteType + "\n" + replaceSpacesPlusSign( getLinkFormattedAddress(getActivity(), siteAddress, siteCity, siteState, siteZipcode)) + "\n" + FORECAST_SHARE_HASHTAG); return shareIntent; }
From source file:com.streaming.sweetplayer.ArtistActivity.java
private Intent getDefaultIntent() { String urlToShare = Config.DOMAIN + mUrl; String sharingText = getString(R.string.sharing_text) + " " + urlToShare + " " + getString(R.string.sharing_android_app) + " " + Config.GOOGLE_PLAY_LINK; Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("text/plain"); sharingIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); sharingIntent.putExtra(Intent.EXTRA_SUBJECT, mDetailName); sharingIntent.putExtra(Intent.EXTRA_TEXT, sharingText); return sharingIntent; }
From source file:com.nutjane.android.MUTram.DetailsFragment.java
private Intent createShareTimetableIntent() { Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_TEXT, mShareValue + TIMETABLE_SHARE_HASHTAG); return shareIntent; }
From source file:net.gsantner.opoc.util.ActivityUtils.java
public void showGooglePlayEntryForThisApp() { String pkgId = "details?id=" + _activity.getPackageName(); Intent goToMarket = new Intent(Intent.ACTION_VIEW, Uri.parse("market://" + pkgId)); goToMarket/*from w w w . java 2 s. c o m*/ .addFlags( Intent.FLAG_ACTIVITY_NO_HISTORY | (Build.VERSION.SDK_INT >= 21 ? Intent.FLAG_ACTIVITY_NEW_DOCUMENT : Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET) | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); try { _activity.startActivity(goToMarket); } catch (ActivityNotFoundException e) { _activity.startActivity( new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/" + pkgId))); } }
From source file:saschpe.birthdays.fragment.SocialFragment.java
/** * Called immediately after {@link #onCreateView(LayoutInflater, ViewGroup, Bundle)} * has returned, but before any saved state has been restored in to the view. * This gives subclasses a chance to initialize themselves once * they know their view hierarchy has been completely created. The fragment's * view hierarchy is not however attached to its parent at this point. * * @param view The View returned by {@link #onCreateView(LayoutInflater, ViewGroup, Bundle)}. * @param savedInstanceState If non-null, this fragment is being re-constructed *//*from www. j av a 2 s.c o m*/ @Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); provideFeedback.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String subject = getString(R.string.feedback_mail_subject_template, getString(R.string.app_name)); Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", SUPPORT_EMAIL_ADDRESS[0], null)) .putExtra(Intent.EXTRA_SUBJECT, subject).putExtra(Intent.EXTRA_TEXT, "") .putExtra(Intent.EXTRA_EMAIL, SUPPORT_EMAIL_ADDRESS); startActivity(Intent.createChooser(emailIntent, view.getContext().getString(R.string.send_email))); } }); followTwitter.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { try { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("twitter://user?screen_name=" + TWITTER_NAME))); } catch (ActivityNotFoundException e) { startActivity( new Intent(Intent.ACTION_VIEW, Uri.parse("https://twitter.com/#!/" + TWITTER_NAME))); } } }); rateOnPlayStore.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // To count with Play market back stack, After pressing back button, // to taken back to our application, we need to add following flags to intent. int flags = Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_MULTIPLE_TASK; if (Build.VERSION.SDK_INT >= 21) { flags |= Intent.FLAG_ACTIVITY_NEW_DOCUMENT; } else { //noinspection deprecation flags |= Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET; } Intent goToMarket = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + packageName)) .addFlags(flags); try { startActivity(goToMarket); } catch (ActivityNotFoundException e) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + packageName))); } } }); recommendToFriend.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String subject = getString(R.string.get_app_template, getString(R.string.app_name)); String body = Uri.parse("http://play.google.com/store/apps/details?id=" + packageName).toString(); Intent sharingIntent = new Intent(Intent.ACTION_SEND).setType("text/plain") .putExtra(Intent.EXTRA_SUBJECT, subject).putExtra(Intent.EXTRA_TEXT, body); startActivity(Intent.createChooser(sharingIntent, view.getContext().getString(R.string.share_via))); } }); forkOnGithub.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(Intent.ACTION_VIEW) .setData(Uri.parse("https://github.com/saschpe/BirthdayCalendar"))); } }); }
From source file:de.j4velin.wifiAutoOff.Preferences.java
@Override public boolean onOptionsItemSelected(final MenuItem item) { // action bar overflow menu switch (item.getItemId()) { case R.id.enable: break;/*from w ww . ja v a2 s .c o m*/ case R.id.action_wifi_adv: try { startActivity(new Intent(Settings.ACTION_WIFI_IP_SETTINGS).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); } catch (Exception e) { Toast.makeText(this, R.string.settings_not_found_, Toast.LENGTH_SHORT).show(); } break; case R.id.action_apps: try { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pub:j4velin")) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET)); } catch (ActivityNotFoundException anf) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/developer?id=j4velin")) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET)); } break; case R.id.action_donate: startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://j4velin.de/donate.php")) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); break; default: return super.onOptionsItemSelected(item); } return true; }
From source file:ch.luklanis.esscan.history.HistoryActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.history_menu_send_dta_save: case R.id.history_menu_send_dta_other: case R.id.history_menu_send_dta_email: { Message message = Message.obtain(mDataSentHandler, item.getItemId()); createDTAFile(message);/*from ww w . j ava 2 s .c o m*/ } break; case R.id.history_menu_send_csv: { CharSequence history = mHistoryManager.buildHistory(); Uri historyFile = HistoryManager.saveHistory(history.toString()); String[] recipients = new String[] { PreferenceManager.getDefaultSharedPreferences(this) .getString(PreferencesActivity.KEY_EMAIL_ADDRESS, "") }; if (historyFile == null) { setOkAlert(R.string.msg_unmount_usb); } else { Intent intent = new Intent(Intent.ACTION_SEND, Uri.parse("mailto:")); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); intent.putExtra(Intent.EXTRA_EMAIL, recipients); String subject = getResources().getString(R.string.history_email_title); intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_TEXT, subject); intent.putExtra(Intent.EXTRA_STREAM, historyFile); intent.setType("text/csv"); startActivity(intent); } } break; case R.id.history_menu_clear: { new CancelOkDialog(R.string.msg_sure).setOkClickListener(new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { mHistoryManager.clearHistory(); dialogInterface.dismiss(); finish(); } }).show(getFragmentManager(), "HistoryActivity.onOptionsItemSelected"); } break; case android.R.id.home: { int error = PsDetailActivity.savePaymentSlip(this); if (error > 0) { setCancelOkAlert(this, error); return true; } NavUtils.navigateUpTo(this, new Intent(this, CaptureActivity.class)); return true; } case R.id.history_menu_copy_code_row: { PsDetailFragment fragment = (PsDetailFragment) getFragmentManager() .findFragmentById(R.id.ps_detail_container); if (fragment != null) { String completeCode = fragment.getHistoryItem().getResult().getCompleteCode(); addCodeRowToClipboard(completeCode); } } break; case R.id.history_menu_send_code_row: { PsDetailFragment fragment = (PsDetailFragment) getFragmentManager() .findFragmentById(R.id.ps_detail_container); if (fragment != null) { IEsrSender sender = getEsrSender(); if (sender != null) { mSendingProgressDialog.show(); fragment.send(PsDetailFragment.SEND_COMPONENT_CODE_ROW, sender, this.historyFragment.getActivatedPosition()); } else { Message message = Message.obtain(mDataSentHandler, R.id.es_send_failed); message.sendToTarget(); } } } break; default: return super.onOptionsItemSelected(item); } return true; }