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.google.samples.apps.iosched.ui.SessionDetailFragment.java
private void buildLinksSection(Cursor cursor) { final Context context = mRootView.getContext(); // Compile list of links (I/O live link, submit feedback, and normal links) ViewGroup linkContainer = (ViewGroup) mRootView.findViewById(R.id.links_container); linkContainer.removeAllViews();//w w w .j a v a2 s . co m // Build links section // the Object can be either a string URL or an Intent List<Pair<Integer, Object>> links = new ArrayList<Pair<Integer, Object>>(); long currentTimeMillis = UIUtils.getCurrentTime(context); if (mHasLivestream && currentTimeMillis > mSessionStart && currentTimeMillis <= mSessionEnd) { links.add(new Pair<Integer, Object>(R.string.session_link_livestream, getWatchLiveIntent(context))); } // Add session feedback link, if appropriate if (!mAlreadyGaveFeedback && currentTimeMillis > mSessionEnd - Config.FEEDBACK_MILLIS_BEFORE_SESSION_END) { links.add(new Pair<Integer, Object>(R.string.session_feedback_submitlink, getFeedbackIntent())); } 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, Object>(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, Object> link = links.get(i); // Create link view TextView linkView = (TextView) inflater.inflate(R.layout.list_item_session_link, linkContainer, false); if (link.first == R.string.session_feedback_submitlink) { mSubmitFeedbackView = linkView; } linkView.setText(getString(link.first)); linkView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { fireLinkEvent(link.first); Intent intent = null; if (link.second instanceof Intent) { intent = (Intent) link.second; } else if (link.second instanceof String) { intent = new Intent(Intent.ACTION_VIEW, Uri.parse((String) link.second)) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); } try { startActivity(intent); } 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); } }
From source file:com.ubuntuone.android.files.activity.FilesActivity.java
private void onOptionPreferencesSelected() { final Intent intent = new Intent(this, PreferencesActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); startActivityForResult(intent, REQUEST_PREFERENCES); }
From source file:com.google.samples.apps.iosched.ui.CurrentSessionActivity.java
private void buildLinksSection(Cursor cursor) { // Compile list of links (I/O live link, submit feedback, and normal links) ViewGroup linkContainer = (ViewGroup) findViewById(R.id.links_container); linkContainer.removeAllViews();//from w ww . ja v a 2 s. co m // Build links section // the Object can be either a string URL or an Intent List<Pair<Integer, Object>> links = new ArrayList<Pair<Integer, Object>>(); long currentTimeMillis = UIUtils.getCurrentTime(this); if (mHasLivestream && currentTimeMillis > mSessionStart && currentTimeMillis <= mSessionEnd) { links.add(new Pair<Integer, Object>(R.string.session_link_livestream, getWatchLiveIntent(this))); } // Add session feedback link, if appropriate if (!mAlreadyGaveFeedback && currentTimeMillis > mSessionEnd - Config.FEEDBACK_MILLIS_BEFORE_SESSION_END) { links.add(new Pair<Integer, Object>(R.string.session_feedback_submitlink, getFeedbackIntent())); } 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, Object>(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(this); int columns = getResources().getInteger(R.integer.links_columns); LinearLayout currentLinkRowView = null; for (int i = 0; i < links.size(); i++) { final Pair<Integer, Object> link = links.get(i); // Create link view TextView linkView = (TextView) inflater.inflate(R.layout.list_item_session_link, linkContainer, false); if (link.first == R.string.session_feedback_submitlink) { mSubmitFeedbackView = linkView; } linkView.setText(getString(link.first)); linkView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { fireLinkEvent(link.first); Intent intent = null; if (link.second instanceof Intent) { intent = (Intent) link.second; } else if (link.second instanceof String) { intent = new Intent(Intent.ACTION_VIEW, Uri.parse((String) link.second)) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); } try { startActivity(intent); } 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); } } findViewById(R.id.session_links_header).setVisibility(View.VISIBLE); findViewById(R.id.links_container).setVisibility(View.VISIBLE); } else { findViewById(R.id.session_links_header).setVisibility(View.GONE); findViewById(R.id.links_container).setVisibility(View.GONE); } }
From source file:com.xgf.inspection.qrcode.google.zxing.client.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 showHelpOnFirstLaunch() { try { PackageInfo info = getPackageManager().getPackageInfo(PACKAGE_NAME, 0); int currentVersion = info.versionCode; SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); int lastVersion = prefs.getInt(PreferencesActivity.KEY_HELP_VERSION_SHOWN, 0); if (currentVersion > lastVersion) { 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.gallery3d.filtershow.FilterShowActivity.java
private Intent getDefaultShareIntent() { Intent intent = new Intent(Intent.ACTION_SEND); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.setType(SharedImageProvider.MIME_TYPE); mSharedOutputFile = SaveImage.getNewFile(this, MasterImage.getImage().getUri()); Uri uri = Uri.withAppendedPath(SharedImageProvider.CONTENT_URI, Uri.encode(mSharedOutputFile.getAbsolutePath())); intent.putExtra(Intent.EXTRA_STREAM, uri); return intent; }
From source file:org.wheelmap.android.fragment.POIDetailFragment.java
private Intent createExternIntent(String action) { Intent intent = new Intent(action); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); return intent; }
From source file:net.networksaremadeofstring.rhybudd.RhybuddHome.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (mDrawerToggle.onOptionsItemSelected(item)) { return true; }/*from ww w. j a v a 2 s .com*/ switch (item.getItemId()) { case R.id.settings: { Intent SettingsIntent = new Intent(RhybuddHome.this, SettingsFragment.class); this.startActivityForResult(SettingsIntent, 99); return true; } /*case R.id.pushconfig: { Intent PushSettingsIntent = new Intent(RhybuddHome.this, PushConfigActivity.class); this.startActivityForResult(PushSettingsIntent, ZenossAPI.ACTIVITYRESULT_PUSHCONFIG); return true; }*/ /*case R.id.Help: { Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse("http://wiki.zenoss.org/index.php?title=Rhybudd#Getting_Started")); startActivity(i); return true; }*/ case R.id.devices: { Intent DeviceList = new Intent(RhybuddHome.this, ViewZenossDeviceListActivity.class); RhybuddHome.this.startActivityForResult(DeviceList, 20); return true; } case R.id.search: { onSearchRequested(); return true; } /*case R.id.cache: { Intent MangeDBIntent = new Intent(RhybuddHome.this, ManageDatabase.class); RhybuddHome.this.startActivity(MangeDBIntent); return true; }*/ case R.id.resolveall: { final List<String> EventIDs = new ArrayList<String>(); for (ZenossEvent evt : listOfZenossEvents) { if (!evt.getEventState().equals("Acknowledged")) { evt.setProgress(true); AckEventHandler.sendEmptyMessage(0); EventIDs.add(evt.getEVID()); } } AckEventHandler.sendEmptyMessage(0); AckEvent = new Thread() { public void run() { try { /* ZenossAPIv2 ackEventAPI; if(settings.getBoolean("httpBasicAuth", false)) { ackEventAPI = new ZenossAPIv2(settings.getString("userName", ""), settings.getString("passWord", ""), settings.getString("URL", ""),settings.getString("BAUser", ""), settings.getString("BAPassword", "")); } else { ackEventAPI = new ZenossAPIv2(settings.getString("userName", ""), settings.getString("passWord", ""), settings.getString("URL", "")); } ackEventAPI.AcknowledgeEvents(EventIDs);//ackEventAPI */ //TODO Check it actually succeeded AckEventHandler.sendEmptyMessage(1); } catch (Exception e) { e.printStackTrace(); AckEventHandler.sendEmptyMessage(99); } } }; AckEvent.start(); return true; } case R.id.refresh: { Refresh(); return true; } case R.id.escalate: { Intent intent = new Intent(android.content.Intent.ACTION_SEND); intent.setType("text/plain"); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); // Add data to the intent, the receiving app will decide what to do with it. intent.putExtra(Intent.EXTRA_SUBJECT, "Escalation of Zenoss Events"); String Events = ""; for (ZenossEvent evt : listOfZenossEvents) { Events += evt.getDevice() + " - " + evt.getSummary() + "\r\n\r\n"; } intent.putExtra(Intent.EXTRA_TEXT, Events); startActivity(Intent.createChooser(intent, "How would you like to escalate these events?")); } } return false; }
From source file:com.ncode.android.apps.schedo.ui.EventDetailActivity.java
private void onSpeakersQueryComplete(Cursor cursor) { mSpeakersCursor = true;/*from www . j a v a2 s . 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(EventDetailActivity.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.google.samples.apps.iosched.ui.SessionDetailActivity.java
private void onSpeakersQueryComplete(Cursor cursor) { mSpeakersCursor = true;/*from ww w . ja v a 2s . c om*/ 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(SessionDetailActivity.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.bookkos.bircle.CaptureActivity.java
private void handleDecodeExternally(Result rawResult, ResultHandler resultHandler, Bitmap barcode) { if (barcode != null) { viewfinderView.drawResultBitmap(barcode); }//from w w w . j a v a 2s . co m long resultDurationMS; if (getIntent() == null) { resultDurationMS = DEFAULT_INTENT_RESULT_DURATION_MS; } else { resultDurationMS = getIntent().getLongExtra(Intents.Scan.RESULT_DISPLAY_DURATION_MS, DEFAULT_INTENT_RESULT_DURATION_MS); } if (resultDurationMS > 0) { String rawResultString = String.valueOf(rawResult); if (rawResultString.length() > 32) { rawResultString = rawResultString.substring(0, 32) + " ..."; } } if (source == IntentSource.NATIVE_APP_INTENT) { // Hand back whatever action they requested - this can be changed to Intents.Scan.ACTION when // the deprecated intent is retired. Intent intent = new Intent(getIntent().getAction()); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); intent.putExtra(Intents.Scan.RESULT, rawResult.toString()); intent.putExtra(Intents.Scan.RESULT_FORMAT, rawResult.getBarcodeFormat().toString()); byte[] rawBytes = rawResult.getRawBytes(); if (rawBytes != null && rawBytes.length > 0) { intent.putExtra(Intents.Scan.RESULT_BYTES, rawBytes); } Map<ResultMetadataType, ?> metadata = rawResult.getResultMetadata(); if (metadata != null) { if (metadata.containsKey(ResultMetadataType.UPC_EAN_EXTENSION)) { intent.putExtra(Intents.Scan.RESULT_UPC_EAN_EXTENSION, metadata.get(ResultMetadataType.UPC_EAN_EXTENSION).toString()); } Number orientation = (Number) metadata.get(ResultMetadataType.ORIENTATION); if (orientation != null) { intent.putExtra(Intents.Scan.RESULT_ORIENTATION, orientation.intValue()); } String ecLevel = (String) metadata.get(ResultMetadataType.ERROR_CORRECTION_LEVEL); if (ecLevel != null) { intent.putExtra(Intents.Scan.RESULT_ERROR_CORRECTION_LEVEL, ecLevel); } @SuppressWarnings("unchecked") Iterable<byte[]> byteSegments = (Iterable<byte[]>) metadata.get(ResultMetadataType.BYTE_SEGMENTS); if (byteSegments != null) { int i = 0; for (byte[] byteSegment : byteSegments) { intent.putExtra(Intents.Scan.RESULT_BYTE_SEGMENTS_PREFIX + i, byteSegment); i++; } } } sendReplyMessage(R.id.return_scan_result, intent, resultDurationMS); } else if (source == IntentSource.PRODUCT_SEARCH_LINK) { // Reformulate the URL which triggered us into a query, so that the request goes to the same // TLD as the scan URL. int end = sourceUrl.lastIndexOf("/scan"); String replyURL = sourceUrl.substring(0, end) + "?q=" + resultHandler.getDisplayContents() + "&source=zxing"; sendReplyMessage(R.id.launch_product_query, replyURL, resultDurationMS); } else if (source == IntentSource.ZXING_LINK) { } }