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.gdgdevfest.android.apps.devfestbcn.ui.SessionDetailFragment.java
/** * Handle {@link SessionsQuery} {@link Cursor}. *///from w w w . j av a 2 s .c o m private void onSessionQueryComplete(Cursor cursor) { mSessionCursor = true; if (!cursor.moveToFirst()) { if (isAdded()) { // TODO: Remove this in favor of a callbacks interface that the activity // can implement. getActivity().finish(); } return; } mTitleString = cursor.getString(SessionsQuery.TITLE); // Format time block this session occupies mSessionBlockStart = cursor.getLong(SessionsQuery.BLOCK_START); mSessionBlockEnd = cursor.getLong(SessionsQuery.BLOCK_END); String roomName = cursor.getString(SessionsQuery.ROOM_NAME); final String subtitle = UIUtils.formatSessionSubtitle(mTitleString, mSessionBlockStart, mSessionBlockEnd, roomName, mBuffer, getActivity()); mTitle.setText(mTitleString); mUrl = cursor.getString(SessionsQuery.URL); if (TextUtils.isEmpty(mUrl)) { mUrl = ""; } mHashtags = cursor.getString(SessionsQuery.HASHTAGS); if (!TextUtils.isEmpty(mHashtags)) { enableSocialStreamMenuItemDeferred(); } mRoomId = cursor.getString(SessionsQuery.ROOM_ID); setupShareMenuItemDeferred(); showStarredDeferred(mInitStarred = (cursor.getInt(SessionsQuery.STARRED) != 0), false); final String sessionAbstract = cursor.getString(SessionsQuery.ABSTRACT); if (!TextUtils.isEmpty(sessionAbstract)) { UIUtils.setTextMaybeHtml(mAbstract, sessionAbstract); mAbstract.setVisibility(View.VISIBLE); mHasSummaryContent = true; } else { mAbstract.setVisibility(View.GONE); } updatePlusOneButton(); final View requirementsBlock = mRootView.findViewById(R.id.session_requirements_block); final String sessionRequirements = cursor.getString(SessionsQuery.REQUIREMENTS); if (!TextUtils.isEmpty(sessionRequirements)) { UIUtils.setTextMaybeHtml(mRequirements, sessionRequirements); requirementsBlock.setVisibility(View.VISIBLE); mHasSummaryContent = true; } else { requirementsBlock.setVisibility(View.GONE); } // Show empty message when all data is loaded, and nothing to show if (mSpeakersCursor && !mHasSummaryContent) { mRootView.findViewById(android.R.id.empty).setVisibility(View.VISIBLE); } // Compile list of links (I/O live link, submit feedback, and normal links) ViewGroup linkContainer = (ViewGroup) mRootView.findViewById(R.id.links_container); linkContainer.removeAllViews(); final Context context = mRootView.getContext(); List<Pair<Integer, Intent>> links = new ArrayList<Pair<Integer, Intent>>(); final boolean hasLivestream = !TextUtils.isEmpty(cursor.getString(SessionsQuery.LIVESTREAM_URL)); long currentTimeMillis = UIUtils.getCurrentTime(context); if (UIUtils.hasHoneycomb() // Needs Honeycomb+ for the live stream && hasLivestream && currentTimeMillis > mSessionBlockStart && currentTimeMillis <= mSessionBlockEnd) { links.add(new Pair<Integer, Intent>(R.string.session_link_livestream, new Intent(Intent.ACTION_VIEW, mSessionUri).setClass(context, SessionLivestreamActivity.class))); } // Add session feedback link // links.add(new Pair<Integer, Intent>( // R.string.session_feedback_submitlink, // new Intent(Intent.ACTION_VIEW, mSessionUri, getActivity(), SessionFeedbackActivity.class) // )); for (int i = 0; i < SessionsQuery.LINKS_INDICES.length; i++) { final String linkUrl = cursor.getString(SessionsQuery.LINKS_INDICES[i]); if (TextUtils.isEmpty(linkUrl)) { continue; } links.add(new Pair<Integer, Intent>(SessionsQuery.LINKS_TITLES[i], new Intent(Intent.ACTION_VIEW, Uri.parse(linkUrl)) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET))); } // Render links if (links.size() > 0) { LayoutInflater inflater = LayoutInflater.from(context); int columns = context.getResources().getInteger(R.integer.links_columns); LinearLayout currentLinkRowView = null; for (int i = 0; i < links.size(); i++) { final Pair<Integer, Intent> link = links.get(i); // Create link view TextView linkView = (TextView) inflater.inflate(R.layout.list_item_session_link, linkContainer, false); linkView.setText(getString(link.first)); linkView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { fireLinkEvent(link.first); try { startActivity(link.second); } catch (ActivityNotFoundException ignored) { } } }); // Place it inside a container if (columns == 1) { linkContainer.addView(linkView); } else { // create a new link row if (i % columns == 0) { currentLinkRowView = (LinearLayout) inflater.inflate(R.layout.include_link_row, linkContainer, false); currentLinkRowView.setWeightSum(columns); linkContainer.addView(currentLinkRowView); } ((LinearLayout.LayoutParams) linkView.getLayoutParams()).width = 0; ((LinearLayout.LayoutParams) linkView.getLayoutParams()).weight = 1; currentLinkRowView.addView(linkView); } } mRootView.findViewById(R.id.session_links_header).setVisibility(View.VISIBLE); mRootView.findViewById(R.id.links_container).setVisibility(View.VISIBLE); } else { mRootView.findViewById(R.id.session_links_header).setVisibility(View.GONE); mRootView.findViewById(R.id.links_container).setVisibility(View.GONE); } // Show past/present/future and livestream status for this block. UIUtils.updateTimeAndLivestreamBlockUI(context, mSessionBlockStart, mSessionBlockEnd, hasLivestream, null, mSubtitle, subtitle); EasyTracker.getTracker().sendView("Session: " + mTitleString); LOGD("Tracker", "Session: " + mTitleString); }
From source file:com.necisstudio.highlightgoal.MainActivity.java
void drawermenu(int id) { if (id == R.id.rate) { Uri uri = Uri.parse("market://details?id=com.necisstudio.highlightgoal"); Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri); goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); try {/*w w w. j a va 2 s. c o m*/ startActivity(goToMarket); } catch (ActivityNotFoundException e) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=com.necisstudio.highlightgoal"))); } } else if (id == R.id.feedback) { Intent send = new Intent(Intent.ACTION_SENDTO); String uriText = "mailto:" + Uri.encode("report@necistudio.com") + "?subject=" + Uri.encode("Feedback for Highlight Goal") + "&body=" + Uri.encode(""); Uri uri = Uri.parse(uriText); send.setData(uri); startActivity(Intent.createChooser(send, "Send mail...")); } else if (id == R.id.latest) { ApplicationConfig.status = id; iddrawer = id; imgLogo.setImageResource(0); txtTitle.setText("Latest"); fList = new ArrayList<Fragment>(); List<Fragment> fragments = getFragments(HighlightLatestFragment.newInstance(""), KlasementLigaFragment.newInstance("inggris"), ScheduleLigaLatestFragment.newInstance("")); adapter_viewPager = new Adapter_ViewPager(getSupportFragmentManager(), fragments); final ViewPager pager = (ViewPager) findViewById(R.id.viewpager); tabHost = (TabLayout) findViewById(R.id.materialTabHost); pager.setAdapter(adapter_viewPager); pager.setOffscreenPageLimit(3); tabHost.setupWithViewPager(pager); tabHost.getTabAt(0).setText("Highlight"); tabHost.getTabAt(1).setText("Schedule"); } else if (id == R.id.inggris) { ApplicationConfig.status = id; iddrawer = id; imgLogo.setImageResource(R.mipmap.premier); txtTitle.setText("Premier League"); fList = new ArrayList<Fragment>(); List<Fragment> fragments = getFragments(HighlightFragment.newInstance("inggris"), KlasementLigaFragment.newInstance("inggris"), ScheduleLigaFragment.newInstance("inggris")); adapter_viewPager = new Adapter_ViewPager(getSupportFragmentManager(), fragments); final ViewPager pager = (ViewPager) findViewById(R.id.viewpager); tabHost = (TabLayout) findViewById(R.id.materialTabHost); pager.setAdapter(adapter_viewPager); pager.setOffscreenPageLimit(3); tabHost.setupWithViewPager(pager); tabHost.getTabAt(0).setText("Highlight"); tabHost.getTabAt(1).setText("Standings"); tabHost.getTabAt(2).setText("Schedule"); } else if (id == R.id.europa) { ApplicationConfig.status = id; iddrawer = id; imgLogo.setImageResource(R.mipmap.europa); txtTitle.setText("Europa League"); fList = new ArrayList<Fragment>(); List<Fragment> fragments = getFragments(HighlightFragment.newInstance("europa"), new TeamEuropaFragment(), ScheduleLigaFragment.newInstance("europa")); adapter_viewPager = new Adapter_ViewPager(getSupportFragmentManager(), fragments); final ViewPager pager = (ViewPager) findViewById(R.id.viewpager); tabHost = (TabLayout) findViewById(R.id.materialTabHost); pager.setAdapter(adapter_viewPager); pager.setOffscreenPageLimit(3); tabHost.setupWithViewPager(pager); tabHost.getTabAt(0).setText("Highlight"); tabHost.getTabAt(1).setText("Standings"); tabHost.getTabAt(2).setText("Schedule"); } else if (id == R.id.champion) { ApplicationConfig.status = id; iddrawer = id; imgLogo.setImageResource(R.mipmap.champion); txtTitle.setText("Champions League"); fList = new ArrayList<Fragment>(); List<Fragment> fragments = getFragments(HighlightFragment.newInstance("champions"), new TeamChampionsFragment(), ScheduleLigaFragment.newInstance("champions")); adapter_viewPager = new Adapter_ViewPager(getSupportFragmentManager(), fragments); final ViewPager pager = (ViewPager) findViewById(R.id.viewpager); tabHost = (TabLayout) findViewById(R.id.materialTabHost); pager.setAdapter(adapter_viewPager); pager.setOffscreenPageLimit(3); tabHost.setupWithViewPager(pager); tabHost.getTabAt(0).setText("Highlight"); tabHost.getTabAt(1).setText("Standings"); tabHost.getTabAt(2).setText("Schedule"); } else if (id == R.id.seria) { ApplicationConfig.status = id; iddrawer = id; imgLogo.setImageResource(R.mipmap.seria); txtTitle.setText("Seri A"); fList = new ArrayList<Fragment>(); List<Fragment> fragments = getFragments(HighlightFragment.newInstance("italia"), KlasementLigaFragment.newInstance("italia"), ScheduleLigaFragment.newInstance("italia")); adapter_viewPager = new Adapter_ViewPager(getSupportFragmentManager(), fragments); final ViewPager pager = (ViewPager) findViewById(R.id.viewpager); tabHost = (TabLayout) findViewById(R.id.materialTabHost); pager.setAdapter(adapter_viewPager); pager.setOffscreenPageLimit(3); tabHost.setupWithViewPager(pager); tabHost.getTabAt(0).setText("Highlight"); tabHost.getTabAt(1).setText("Standings"); tabHost.getTabAt(2).setText("Schedule"); } else if (id == R.id.jerman) { ApplicationConfig.status = id; iddrawer = id; imgLogo.setImageResource(R.mipmap.bundes); txtTitle.setText("Bundesliga"); fList = new ArrayList<Fragment>(); List<Fragment> fragments = getFragments(HighlightFragment.newInstance("jerman"), KlasementLigaFragment.newInstance("jerman"), ScheduleLigaFragment.newInstance("jerman")); adapter_viewPager = new Adapter_ViewPager(getSupportFragmentManager(), fragments); final ViewPager pager = (ViewPager) findViewById(R.id.viewpager); tabHost = (TabLayout) findViewById(R.id.materialTabHost); pager.setAdapter(adapter_viewPager); pager.setOffscreenPageLimit(3); tabHost.setupWithViewPager(pager); tabHost.getTabAt(0).setText("Highlight"); tabHost.getTabAt(1).setText("Standings"); tabHost.getTabAt(2).setText("Schedule"); } else if (id == R.id.spain) { ApplicationConfig.status = id; iddrawer = id; imgLogo.setImageResource(R.mipmap.bbva); txtTitle.setText("BBVA League"); fList = new ArrayList<Fragment>(); List<Fragment> fragments = getFragments(HighlightFragment.newInstance("spain"), KlasementLigaFragment.newInstance("spain"), ScheduleLigaFragment.newInstance("spain")); adapter_viewPager = new Adapter_ViewPager(getSupportFragmentManager(), fragments); final ViewPager pager = (ViewPager) findViewById(R.id.viewpager); tabHost = (TabLayout) findViewById(R.id.materialTabHost); pager.setAdapter(adapter_viewPager); pager.setOffscreenPageLimit(3); tabHost.setupWithViewPager(pager); tabHost.getTabAt(0).setText("Highlight"); tabHost.getTabAt(1).setText("Standings"); tabHost.getTabAt(2).setText("Schedule"); } else if (id == R.id.france) { ApplicationConfig.status = id; iddrawer = id; imgLogo.setImageResource(R.mipmap.ligue); txtTitle.setText("League 1"); fList = new ArrayList<Fragment>(); List<Fragment> fragments = getFragments(HighlightFragment.newInstance("france"), KlasementLigaFragment.newInstance("france"), ScheduleLigaFragment.newInstance("france")); adapter_viewPager = new Adapter_ViewPager(getSupportFragmentManager(), fragments); final ViewPager pager = (ViewPager) findViewById(R.id.viewpager); tabHost = (TabLayout) findViewById(R.id.materialTabHost); pager.setAdapter(adapter_viewPager); pager.setOffscreenPageLimit(3); tabHost.setupWithViewPager(pager); tabHost.getTabAt(0).setText("Highlight"); tabHost.getTabAt(1).setText("Standings"); tabHost.getTabAt(2).setText("Schedule"); } else if (id == R.id.about) { Intent intent = new Intent(MainActivity.this, ActivityAbout.class); startActivity(intent); } else if (id == R.id.license) { Intent intent = new Intent(MainActivity.this, ActivityLicense.class); startActivity(intent); } }
From source file:com.google.samples.apps.iosched.session.SessionDetailModel.java
private int getFlagForUrlLink() { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { return Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET; } else {/* w ww . ja v a 2 s.c om*/ return Intent.FLAG_ACTIVITY_NEW_DOCUMENT; } }
From source file:org.dharmaseed.android.PlayTalkActivity.java
/** * Share a link to the dharmaseed website for this talk *//* w w w .j a va 2 s .c o m*/ public void onShareButtonClicked(View view) { String url = String.format("https://dharmaseed.org/teacher/%d/talk/%d/", talk.getTeacherId(), talk.getId()); Log.d(LOG_TAG, "Sharing link to " + url); Intent share = new Intent(android.content.Intent.ACTION_SEND); share.setType("text/plain"); share.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); // Add data to the intent, the receiving app will decide // what to do with it. share.putExtra(Intent.EXTRA_SUBJECT, talk.getTitle()); share.putExtra(Intent.EXTRA_TEXT, url); startActivity(Intent.createChooser(share, "Share talk")); }
From source file:zjut.com.laowuguanli.activity.MainActivity.java
private void shareQuestion() { Intent share = new Intent(android.content.Intent.ACTION_SEND); share.setType("text/plain"); //noinspection deprecation share.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); share.putExtra(Intent.EXTRA_TEXT,/* w w w. j a va 2 s . com*/ "???????"); startActivity(Intent.createChooser(share, "")); }
From source file:org.catrobat.paintroid.MainActivity.java
private void importPng() { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("image/*"); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); startActivityForResult(intent, REQUEST_CODE_IMPORTPNG); }
From source file:net.abcdroid.devfest12.ui.SessionDetailFragment.java
private void onSpeakersQueryComplete(Cursor cursor) { mSpeakersCursor = true;/*from w w w .j a v a2 s . c o m*/ // TODO: remove existing speakers from layout, since this cursor might be from a data change final ViewGroup speakersGroup = (ViewGroup) mRootView.findViewById(R.id.session_speakers_block); 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)) { mImageFetcher.loadThumbnailImage(speakerImageUrl, speakerImageView, R.drawable.person_image_empty); } 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); UIUtils.safeOpenLink(getActivity(), 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:ch.luklanis.esscan.history.HistoryActivity.java
private Intent createShareIntent(String mime, Uri dtaFileUri) { String[] recipients = new String[] { PreferenceManager.getDefaultSharedPreferences(this) .getString(PreferencesActivity.KEY_EMAIL_ADDRESS, "") }; String subject = getResources().getString(R.string.history_share_as_dta_title); String text = String.format(getResources().getString(R.string.history_share_as_dta_summary), dtaFileUri.getPath());// w ww.ja v a2s .c o m Intent intent = new Intent(Intent.ACTION_SEND, Uri.parse("mailto:")); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); intent.setType(mime); intent.putExtra(Intent.EXTRA_EMAIL, recipients); intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_TEXT, text); intent.putExtra(Intent.EXTRA_STREAM, dtaFileUri); return intent; }
From source file:com.android.mms.rcs.FavoriteDetailAdapter.java
private static void mergeVcardDetail(Context context, ArrayList<PropertyNode> propList) { Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT); intent.setType(Contacts.CONTENT_ITEM_TYPE); ArrayList<ContentValues> phoneValue = new ArrayList<ContentValues>(); for (PropertyNode propertyNode : propList) { if ("FN".equals(propertyNode.propName)) { if (!TextUtils.isEmpty(propertyNode.propValue)) { intent.putExtra(ContactsContract.Intents.Insert.NAME, propertyNode.propValue); }//from w w w .j a v a 2 s . co m } else if ("TEL".equals(propertyNode.propName)) { if (!TextUtils.isEmpty(propertyNode.propValue)) { ContentValues value = new ContentValues(); value.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE); value.put(Phone.TYPE, RcsUtils.getVcardNumberType(propertyNode)); value.put(Phone.NUMBER, propertyNode.propValue); phoneValue.add(value); } } else if ("ADR".equals(propertyNode.propName)) { if (!TextUtils.isEmpty(propertyNode.propValue)) { intent.putExtra(ContactsContract.Intents.Insert.POSTAL, propertyNode.propValue); intent.putExtra(ContactsContract.Intents.Insert.POSTAL_TYPE, ContactsContract.CommonDataKinds.StructuredPostal.TYPE_WORK); } } else if ("ORG".equals(propertyNode.propName)) { if (!TextUtils.isEmpty(propertyNode.propValue)) { intent.putExtra(ContactsContract.Intents.Insert.COMPANY, propertyNode.propValue); } } else if ("TITLE".equals(propertyNode.propName)) { if (!TextUtils.isEmpty(propertyNode.propValue)) { intent.putExtra(ContactsContract.Intents.Insert.JOB_TITLE, propertyNode.propValue); } } } if (phoneValue.size() > 0) { intent.putParcelableArrayListExtra(Insert.DATA, phoneValue); } intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); context.startActivity(intent); }
From source file:com.e2g.ecocicle.barcode.IntentIntegrator.java
/** * Shares the given text by encoding it as a barcode, such that another user can * scan the text off the screen of the device. * * @param text the text string to encode as a barcode * @param type type of data to encode. See {@code com.google.zxing.client.android.Contents.Type} constants. * @return the {@link android.app.AlertDialog} that was shown to the user prompting them to download the app * if a prompt was needed, or null otherwise *///w w w. jav a2 s . c om public final AlertDialog shareText(CharSequence text, CharSequence type) { Intent intent = new Intent(); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.setAction(BS_PACKAGE + ".ENCODE"); intent.putExtra("ENCODE_TYPE", type); intent.putExtra("ENCODE_DATA", text); String targetAppPackage = findTargetAppPackage(intent); if (targetAppPackage == null) { return showDownloadDialog(); } intent.setPackage(targetAppPackage); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); attachMoreExtras(intent); if (fragment == null) { activity.startActivity(intent); } else { fragment.startActivity(intent); } return null; }