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.android.contacts.list.DefaultContactBrowseListFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (mDisableOptionItemSelected) { return false; }//from w w w . j ava 2s. co m final int id = item.getItemId(); if (id == android.R.id.home) { if (mActionBarAdapter.isUpShowing()) { // "UP" icon press -- should be treated as "back". mActivity.onBackPressed(); } return true; } else if (id == R.id.menu_search) { if (!mActionBarAdapter.isSelectionMode()) { mActionBarAdapter.setSearchMode(true); } return true; } else if (id == R.id.menu_share) { shareSelectedContacts(); return true; } else if (id == R.id.menu_join) { Logger.logListEvent(ListEvent.ActionType.LINK, /* listType */ getListTypeIncludingSearch(), /* count */ getAdapter().getCount(), /* clickedIndex */ -1, /* numSelected */ getAdapter().getSelectedContactIds().size()); joinSelectedContacts(); return true; } else if (id == R.id.menu_delete) { deleteSelectedContacts(); return true; } else if (id == R.id.export_database) { final Intent intent = new Intent("com.android.providers.contacts.DUMP_DATABASE"); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); ImplicitIntentsUtil.startActivityOutsideApp(getContext(), intent); return true; } return super.onOptionsItemSelected(item); }
From source file:com.google.samples.apps.iosched.ui.SessionDetailFragment.java
private void onSpeakersQueryComplete(Cursor cursor) { mSpeakersCursor = true;//from w w w .j av a2s. c o m final ViewGroup speakersGroup = (ViewGroup) mRootView.findViewById(R.id.session_speakers_block); // Remove all existing speakers (everything but first child, which is the header) for (int i = speakersGroup.getChildCount() - 1; i >= 1; i--) { speakersGroup.removeViewAt(i); } final LayoutInflater inflater = getActivity().getLayoutInflater(); boolean hasSpeakers = false; while (cursor.moveToNext()) { final String speakerName = cursor.getString(SpeakersQuery.SPEAKER_NAME); if (TextUtils.isEmpty(speakerName)) { continue; } final String speakerImageUrl = cursor.getString(SpeakersQuery.SPEAKER_IMAGE_URL); final String speakerCompany = cursor.getString(SpeakersQuery.SPEAKER_COMPANY); final String speakerUrl = cursor.getString(SpeakersQuery.SPEAKER_URL); final String speakerAbstract = cursor.getString(SpeakersQuery.SPEAKER_ABSTRACT); String speakerHeader = speakerName; if (!TextUtils.isEmpty(speakerCompany)) { speakerHeader += ", " + speakerCompany; } final View speakerView = inflater.inflate(R.layout.speaker_detail, speakersGroup, false); final TextView speakerHeaderView = (TextView) speakerView.findViewById(R.id.speaker_header); final ImageView speakerImageView = (ImageView) speakerView.findViewById(R.id.speaker_image); final TextView speakerAbstractView = (TextView) speakerView.findViewById(R.id.speaker_abstract); if (!TextUtils.isEmpty(speakerImageUrl) && mSpeakersImageLoader != null) { mSpeakersImageLoader.loadImage(speakerImageUrl, speakerImageView); } speakerHeaderView.setText(speakerHeader); speakerImageView.setContentDescription(getString(R.string.speaker_googleplus_profile, speakerHeader)); UIUtils.setTextMaybeHtml(speakerAbstractView, speakerAbstract); if (!TextUtils.isEmpty(speakerUrl)) { speakerImageView.setEnabled(true); speakerImageView.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { Intent speakerProfileIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(speakerUrl)); speakerProfileIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); UIUtils.preferPackageForIntent(getActivity(), speakerProfileIntent, UIUtils.GOOGLE_PLUS_PACKAGE_NAME); startActivity(speakerProfileIntent); } }); } else { speakerImageView.setEnabled(false); speakerImageView.setOnClickListener(null); } speakersGroup.addView(speakerView); hasSpeakers = true; mHasSummaryContent = true; } speakersGroup.setVisibility(hasSpeakers ? View.VISIBLE : View.GONE); // Show empty message when all data is loaded, and nothing to show if (mSessionCursor && !mHasSummaryContent) { mRootView.findViewById(android.R.id.empty).setVisibility(View.VISIBLE); } }
From source file:com.google.samples.apps.iosched.ui.CurrentSessionActivity.java
private void onSpeakersQueryComplete(Cursor cursor) { mSpeakersCursor = true;//w ww.j a v a2s . c o m final ViewGroup speakersGroup = (ViewGroup) findViewById(R.id.session_speakers_block); // Remove all existing speakers (everything but first child, which is the header) for (int i = speakersGroup.getChildCount() - 1; i >= 1; i--) { speakersGroup.removeViewAt(i); } final LayoutInflater inflater = getLayoutInflater(); boolean hasSpeakers = false; cursor.moveToPosition(-1); // move to just before first record while (cursor.moveToNext()) { final String speakerName = cursor.getString(SpeakersQuery.SPEAKER_NAME); if (TextUtils.isEmpty(speakerName)) { continue; } final String speakerImageUrl = cursor.getString(SpeakersQuery.SPEAKER_IMAGE_URL); final String speakerCompany = cursor.getString(SpeakersQuery.SPEAKER_COMPANY); final String speakerUrl = cursor.getString(SpeakersQuery.SPEAKER_URL); final String speakerAbstract = cursor.getString(SpeakersQuery.SPEAKER_ABSTRACT); String speakerHeader = speakerName; if (!TextUtils.isEmpty(speakerCompany)) { speakerHeader += ", " + speakerCompany; } final View speakerView = inflater.inflate(R.layout.speaker_detail, speakersGroup, false); final TextView speakerHeaderView = (TextView) speakerView.findViewById(R.id.speaker_header); final ImageView speakerImageView = (ImageView) speakerView.findViewById(R.id.speaker_image); final TextView speakerAbstractView = (TextView) speakerView.findViewById(R.id.speaker_abstract); if (!TextUtils.isEmpty(speakerImageUrl) && mSpeakersImageLoader != null) { mSpeakersImageLoader.loadImage(speakerImageUrl, speakerImageView); } speakerHeaderView.setText(speakerHeader); speakerImageView.setContentDescription(getString(R.string.speaker_googleplus_profile, speakerHeader)); UIUtils.setTextMaybeHtml(speakerAbstractView, speakerAbstract); if (!TextUtils.isEmpty(speakerUrl)) { speakerImageView.setEnabled(true); speakerImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent speakerProfileIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(speakerUrl)); speakerProfileIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); UIUtils.preferPackageForIntent(CurrentSessionActivity.this, speakerProfileIntent, UIUtils.GOOGLE_PLUS_PACKAGE_NAME); startActivity(speakerProfileIntent); } }); } else { speakerImageView.setEnabled(false); speakerImageView.setOnClickListener(null); } speakersGroup.addView(speakerView); hasSpeakers = true; mHasSummaryContent = true; } speakersGroup.setVisibility(hasSpeakers ? View.VISIBLE : View.GONE); updateEmptyView(); }
From source file:com.android.contacts.activities.PeopleActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (mDisableOptionItemSelected) { return false; }/*from w w w. ja va2 s . com*/ switch (item.getItemId()) { case android.R.id.home: { // The home icon on the action bar is pressed if (mActionBarAdapter.isUpShowing()) { // "UP" icon press -- should be treated as "back". onBackPressed(); } return true; } case R.id.menu_settings: { startActivity(new Intent(this, ContactsPreferenceActivity.class)); return true; } case R.id.menu_contacts_filter: { AccountFilterUtil.startAccountFilterActivityForResult(this, SUBACTIVITY_ACCOUNT_FILTER, mContactListFilterController.getFilter()); return true; } case R.id.menu_search: { onSearchRequested(); return true; } case R.id.menu_share: shareSelectedContacts(); return true; case R.id.menu_join: joinSelectedContacts(); return true; case R.id.menu_delete: deleteSelectedContacts(); return true; case R.id.menu_import_export: { showImportExportDialogFragment(); return true; } case R.id.menu_clear_frequents: { ClearFrequentsDialog.show(getFragmentManager()); return true; } case R.id.menu_help: HelpUtils.launchHelpAndFeedbackForMainScreen(this); return true; case R.id.menu_accounts: { final Intent intent = new Intent(Settings.ACTION_SYNC_SETTINGS); intent.putExtra(Settings.EXTRA_AUTHORITIES, new String[] { ContactsContract.AUTHORITY }); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); ImplicitIntentsUtil.startActivityInAppIfPossible(this, intent); return true; } case R.id.menu_blocked_numbers: { final Intent intent = TelecomManagerUtil .createManageBlockedNumbersIntent((TelecomManager) getSystemService(Context.TELECOM_SERVICE)); if (intent != null) { startActivity(intent); } return true; } case R.id.export_database: { final Intent intent = new Intent("com.android.providers.contacts.DUMP_DATABASE"); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); ImplicitIntentsUtil.startActivityOutsideApp(this, intent); return true; } } return false; }
From source file:com.edible.ocr.CaptureActivity.java
/** * We want the help screen to be shown automatically the first time a new version of the app is * run. The easiest way to do this is to check android:versionCode from the manifest, and compare * it to a value stored as a preference. *//* w w w.j a v a 2 s . c o m*/ private boolean checkFirstLaunch() { try { PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), 0); int currentVersion = info.versionCode; SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); int lastVersion = prefs.getInt(PreferencesActivity.KEY_HELP_VERSION_SHOWN, 0); if (lastVersion == 0) { isFirstLaunch = true; } else { isFirstLaunch = false; } if (currentVersion > lastVersion) { // Record the last version for which we last displayed the What's New (Help) page prefs.edit().putInt(PreferencesActivity.KEY_HELP_VERSION_SHOWN, currentVersion).commit(); Intent intent = new Intent(this, HelpActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); // Show the default page on a clean install, and the what's new page on an upgrade. String page = lastVersion == 0 ? HelpActivity.DEFAULT_PAGE : HelpActivity.WHATS_NEW_PAGE; intent.putExtra(HelpActivity.REQUESTED_PAGE_KEY, page); startActivity(intent); return true; } } catch (PackageManager.NameNotFoundException e) { Log.w(TAG, e); } return false; }
From source file:com.android.email.activity.MessageView.java
/** * Back in the UI thread, handle the final steps of downloading an attachment (view or save). * * @param attachmentId the attachment that was just downloaded *//* w ww . j a v a 2 s .co m*/ private void doFinishLoadAttachment(long attachmentId) { // If the result does't line up, just skip it - we handle one at a time. if (attachmentId != mLoadAttachmentId) { return; } Attachment attachment = Attachment.restoreAttachmentWithId(MessageView.this, attachmentId); Uri attachmentUri = AttachmentProvider.getAttachmentUri(mAccountId, attachment.mId); Uri contentUri = AttachmentProvider.resolveAttachmentIdToContentUri(getContentResolver(), attachmentUri); if (mLoadAttachmentSave) { try { File file = createUniqueFile(Environment.getExternalStorageDirectory(), attachment.mFileName); InputStream in = getContentResolver().openInputStream(contentUri); OutputStream out = new FileOutputStream(file); IOUtils.copy(in, out); out.flush(); out.close(); in.close(); Toast.makeText(MessageView.this, String.format(getString(R.string.message_view_status_attachment_saved), file.getName()), Toast.LENGTH_LONG).show(); new MediaScannerNotifier(this, file, mHandler); } catch (IOException ioe) { Toast.makeText(MessageView.this, getString(R.string.message_view_status_attachment_not_saved), Toast.LENGTH_LONG).show(); } } else { try { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(contentUri); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); startActivity(intent); } catch (ActivityNotFoundException e) { mHandler.attachmentViewError(); // TODO: Add a proper warning message (and lots of upstream cleanup to prevent // it from happening) in the next release. } } }
From source file:com.juick.android.MainActivity.java
private void obtainSavedMessagesURL(final boolean reset) { final ProgressDialog pd = new ProgressDialog(MainActivity.this); pd.setIndeterminate(true);//w ww. j a v a 2 s . c o m pd.setTitle("Saved Messages"); pd.setMessage("Waiting for server key"); pd.setCancelable(true); pd.show(); new Thread("obtainSavedMessagesURL") { @Override public void run() { final RESTResponse restResponse = DatabaseService.obtainSharingURL(MainActivity.this, reset); if (restResponse.getErrorText() == null) try { new JSONObject(restResponse.getResult()); } catch (JSONException e) { restResponse.errorText = e.toString(); } runOnUiThread(new Runnable() { @Override public void run() { pd.cancel(); if (restResponse.getErrorText() != null) { Toast.makeText(MainActivity.this, restResponse.getErrorText(), Toast.LENGTH_LONG) .show(); } else { try { final String url = (String) new JSONObject(restResponse.getResult()).get("url"); if (url.length() == 0) { Toast.makeText(MainActivity.this, "You don't have key yet. Choose another option.", Toast.LENGTH_LONG) .show(); } else { new AlertDialog.Builder(MainActivity.this).setTitle("You got key!") .setMessage(url) .setPositiveButton("Ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).setNeutralButton("Share with..", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent share = new Intent( android.content.Intent.ACTION_SEND); share.setType("text/plain"); share.addFlags( Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); share.putExtra(Intent.EXTRA_SUBJECT, "My Saved messages on Juick Advanced"); share.putExtra(Intent.EXTRA_TEXT, url); startActivity( Intent.createChooser(share, "Share link")); } }) .setCancelable(true).show(); } } catch (JSONException e) { Toast.makeText(MainActivity.this, e.toString(), Toast.LENGTH_LONG).show(); } } } }); } }.start(); }
From source file:org.mdc.chess.MDChess.java
private void shareGame() { Intent i = new Intent(Intent.ACTION_SEND); //noinspection deprecation i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); i.setType("text/plain"); i.putExtra(Intent.EXTRA_TEXT, ctrl.getPGN()); try {/*from w ww.j a v a 2s . com*/ startActivity(Intent.createChooser(i, getString(R.string.share_pgn_game))); } catch (ActivityNotFoundException ex) { // Ignore } }