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.irccloud.android.activity.VideoPlayerActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_videoplayer, menu); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M && getIntent() != null && getIntent().getDataString() != null) { Intent intent = new Intent(Intent.ACTION_SEND, Uri.parse( getIntent().getDataString().replace(getResources().getString(R.string.VIDEO_SCHEME), "http"))); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, getIntent().getDataString().replace(getResources().getString(R.string.VIDEO_SCHEME), "http")); intent.putExtra(ShareCompat.EXTRA_CALLING_PACKAGE, getPackageName()); intent.putExtra(ShareCompat.EXTRA_CALLING_ACTIVITY, getPackageManager().getLaunchIntentForPackage(getPackageName()).getComponent()); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET | Intent.FLAG_ACTIVITY_NEW_TASK); MenuItem shareItem = menu.findItem(R.id.action_share); share = (ShareActionProviderHax) MenuItemCompat.getActionProvider(shareItem); share.onShareActionProviderSubVisibilityChangedListener = this; share.setOnShareTargetSelectedListener(new ShareActionProvider.OnShareTargetSelectedListener() { @Override/* ww w .j ava2s . co m*/ public boolean onShareTargetSelected(ShareActionProvider source, Intent intent) { String name = intent.getComponent().getPackageName(); try { name = String.valueOf(getPackageManager().getActivityInfo(intent.getComponent(), 0) .loadLabel(getPackageManager())); } catch (PackageManager.NameNotFoundException e) { NetworkConnection.printStackTraceToCrashlytics(e); } Answers.getInstance().logShare(new ShareEvent().putContentType("Video").putMethod(name)); return false; } }); share.setShareIntent(intent); } else { MenuItem shareItem = menu.findItem(R.id.action_share); if (shareItem != null && shareItem.getIcon() != null) shareItem.getIcon().mutate().setColorFilter(0xFFCCCCCC, PorterDuff.Mode.SRC_ATOP); } return true; }
From source file:com.tasomaniac.openwith.resolver.ResolverActivity.java
@SuppressWarnings("deprecation") void showAppDetails(ResolveInfo ri) { Intent in = new Intent().setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS) .setData(Uri.fromParts("package", ri.activityInfo.packageName, null)) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); startActivity(in);/*w w w . j a v a 2s. c om*/ }
From source file:org.kiwix.kiwixmobile.KiwixMobileActivity.java
private void goToRateApp() { Intent goToMarket = new Intent(Intent.ACTION_VIEW, KIWIX_LOCAL_MARKET_URI); goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); try {//w ww . ja v a 2s .com startActivity(goToMarket); } catch (ActivityNotFoundException e) { startActivity(new Intent(Intent.ACTION_VIEW, KIWIX_BROWSER_MARKET_URI)); } }
From source file:com.nikhilnayak.games.octoshootar.ui.fragments.GameScoreFragment.java
private void handleShareScore() { new AsyncTask<Void, Void, Uri>() { @Override/*from ww w. j av a 2 s . com*/ protected Uri doInBackground(Void... params) { final Bitmap bitmapToShare = getBitmapToShare(); //Compress the bitmap before saving and sharing. ByteArrayOutputStream bytes = new ByteArrayOutputStream(); bitmapToShare.compress(Bitmap.CompressFormat.JPEG, BITMAP_QUALITY, bytes); bitmapToShare.recycle(); final Uri uriToShare = writeScoreBytesToExternalStorage(bytes); return uriToShare; } @Override protected void onPostExecute(Uri uri) { super.onPostExecute(uri); if (uri != null) { // Add the screen to the Media Provider's database. Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); mediaScanIntent.setData(uri); getActivity().sendBroadcast(mediaScanIntent); // Share intent Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); shareIntent.setType("image/*"); shareIntent.putExtra(Intent.EXTRA_STREAM, uri); getActivity().startActivity(shareIntent); } } }.execute(); }
From source file:com.ravi.apps.android.newsbytes.DetailsFragment.java
/** * Returns an intent with the news headline, summary and uri added as extras. *///from w w w .j a v a 2 s .c o m private Intent createNewsShareIntent() { Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); shareIntent.setType(getString(R.string.type_share_intent)); shareIntent.putExtra(Intent.EXTRA_SUBJECT, getHeadline()); shareIntent.putExtra(Intent.EXTRA_TEXT, getSummary() + getString(R.string.msg_read_more) + getUriStory()); return shareIntent; }
From source file:com.abewy.android.apps.klyph.app.MainActivity.java
private void updateContent(int selection) { if (selection != oldSelection) { Bundle bundle = new Bundle(); bundle.putString(KlyphBundleExtras.ELEMENT_ID, KlyphSession.getSessionUserId()); String className = classes.get(selection); if (className.equals("com.abewy.android.apps.klyph.fragment.Chat")) { PackageManager pm = getPackageManager(); try { pm.getPackageInfo(MESSENGER_PACKAGE_NAME, PackageManager.GET_ACTIVITIES); Intent intent = getPackageManager().getLaunchIntentForPackage(MESSENGER_PACKAGE_NAME); startActivity(intent);/* w w w . j av a 2s .c o m*/ } catch (NameNotFoundException e) { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(MESSENGER_PLAY_STORE_URI)); intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); startActivity(intent); } } else { if (selection < navAdapter.getCount()) setTitle(navAdapter.getItem(selection)); else setTitle(KlyphSession.getSessionUserName()); Fragment fragment = Fragment.instantiate(MainActivity.this, className, bundle); if (previousFragment != null) previousFragment.onSetToBack(this); FragmentTransaction tx = getFragmentManager().beginTransaction(); tx.replace(R.id.main, fragment, FRAGMENT_TAG); tx.commitAllowingStateLoss(); ((IKlyphFragment) fragment).onSetToFront(this); previousFragment = (IKlyphFragment) fragment; navAdapter.setSelectedPosition(selection); navAdapter.notifyDataSetChanged(); oldSelection = selection; if (notificationsFragment != null) notificationsFragment.setHasOptionsMenu(false); } } }
From source file:com.abewy.android.apps.openklyph.app.MainActivity.java
private void updateContent(int selection) { if (selection != oldSelection) { Bundle bundle = new Bundle(); bundle.putString(KlyphBundleExtras.ELEMENT_ID, KlyphSession.getSessionUserId()); String className = classes.get(selection); if (className.equals("com.abewy.android.apps.openklyph.fragment.Chat")) { PackageManager pm = getPackageManager(); try { pm.getPackageInfo(MESSENGER_PACKAGE_NAME, PackageManager.GET_ACTIVITIES); Intent intent = getPackageManager().getLaunchIntentForPackage(MESSENGER_PACKAGE_NAME); startActivity(intent);// w w w.j ava 2 s . co m } catch (NameNotFoundException e) { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(MESSENGER_PLAY_STORE_URI)); intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); startActivity(intent); } } else { if (selection < navAdapter.getCount()) setTitle(navAdapter.getItem(selection)); else setTitle(KlyphSession.getSessionUserName()); Fragment fragment = Fragment.instantiate(MainActivity.this, className, bundle); if (previousFragment != null) previousFragment.onSetToBack(this); FragmentTransaction tx = getFragmentManager().beginTransaction(); tx.replace(R.id.main, fragment, FRAGMENT_TAG); tx.commitAllowingStateLoss(); ((IKlyphFragment) fragment).onSetToFront(this); previousFragment = (IKlyphFragment) fragment; navAdapter.setSelectedPosition(selection); navAdapter.notifyDataSetChanged(); oldSelection = selection; if (notificationsFragment != null) notificationsFragment.setHasOptionsMenu(false); } } }
From source file:com.google.zxing.client.android.result.ResultHandler.java
/** * Like {@link #launchIntent(Intent)} but will tell you if it is not handle-able * via {@link ActivityNotFoundException}. * * @throws ActivityNotFoundException// ww w . j a v a 2s. c o m */ final void rawLaunchIntent(Intent intent) { if (intent != null) { intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); Log.d(TAG, "Launching intent: " + intent + " with extras: " + intent.getExtras()); activity.startActivity(intent); } }
From source file:com.conferenceengineer.android.iosched.ui.SessionDetailFragment.java
private void onSpeakersQueryComplete(Cursor cursor) { mSpeakersCursor = true;/* w ww . ja va 2s. com*/ 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) && mImageLoader != null) { mImageLoader.get(UIUtils.getConferenceImageUrl(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); 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.android.mms.ui.ConversationList.java
@Override public boolean onContextItemSelected(MenuItem item) { Cursor cursor = mListAdapter.getCursor(); if (cursor != null && cursor.getPosition() >= 0) { Conversation conv = Conversation.from(ConversationList.this, cursor); long threadId = conv.getThreadId(); switch (item.getItemId()) { case MENU_DELETE: { confirmDeleteThread(threadId, mQueryHandler); break; }//from w w w . j a v a 2 s . com case MENU_VIEW: { openThread(threadId); break; } case MENU_VIEW_CONTACT: { Contact contact = conv.getRecipients().get(0); Intent intent = new Intent(Intent.ACTION_VIEW, contact.getUri()); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); startActivity(intent); break; } case MENU_ADD_TO_CONTACTS: { String address = conv.getRecipients().get(0).getNumber(); startActivity(createAddContactIntent(address)); break; } default: break; } } return super.onContextItemSelected(item); }