List of usage examples for android.content Intent createChooser
public static Intent createChooser(Intent target, CharSequence title)
From source file:com.dwdesign.tweetings.fragment.StatusFragment.java
@SuppressLint({ "NewApi", "NewApi", "NewApi" }) @Override/*from ww w . jav a 2 s.co m*/ public boolean onMenuItemClick(final MenuItem item) { if (mStatus == null) return false; final String text_plain = mStatus.text_plain; final String screen_name = mStatus.screen_name; final String name = mStatus.name; switch (item.getItemId()) { case MENU_SHARE: { final Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, "@" + mStatus.screen_name + ": " + text_plain); startActivity(Intent.createChooser(intent, getString(R.string.share))); break; } case MENU_RETWEET: { if (isMyRetweet(mStatus)) { mService.destroyStatus(mAccountId, mStatus.retweet_id); } else { final long id_to_retweet = mStatus.is_retweet && mStatus.retweet_id > 0 ? mStatus.retweet_id : mStatus.status_id; mService.retweetStatus(mAccountId, id_to_retweet); } break; } case MENU_TRANSLATE: { translate(mStatus); break; } case MENU_QUOTE_REPLY: { final Intent intent = new Intent(INTENT_ACTION_COMPOSE); final Bundle bundle = new Bundle(); bundle.putLong(INTENT_KEY_ACCOUNT_ID, mAccountId); bundle.putLong(INTENT_KEY_IN_REPLY_TO_ID, mStatusId); bundle.putString(INTENT_KEY_IN_REPLY_TO_SCREEN_NAME, screen_name); bundle.putString(INTENT_KEY_IN_REPLY_TO_NAME, name); bundle.putBoolean(INTENT_KEY_IS_QUOTE, true); bundle.putString(INTENT_KEY_TEXT, getQuoteStatus(getActivity(), screen_name, text_plain)); intent.putExtras(bundle); startActivity(intent); break; } case MENU_QUOTE: { final Intent intent = new Intent(INTENT_ACTION_COMPOSE); final Bundle bundle = new Bundle(); bundle.putLong(INTENT_KEY_ACCOUNT_ID, mAccountId); bundle.putBoolean(INTENT_KEY_IS_QUOTE, true); bundle.putString(INTENT_KEY_TEXT, getQuoteStatus(getActivity(), screen_name, text_plain)); intent.putExtras(bundle); startActivity(intent); break; } case MENU_ADD_TO_BUFFER: { final Intent intent = new Intent(INTENT_ACTION_COMPOSE); final Bundle bundle = new Bundle(); bundle.putLong(INTENT_KEY_ACCOUNT_ID, mAccountId); bundle.putBoolean(INTENT_KEY_IS_BUFFER, true); bundle.putString(INTENT_KEY_TEXT, getQuoteStatus(getActivity(), screen_name, text_plain)); intent.putExtras(bundle); startActivity(intent); break; } case MENU_REPLY: { final Intent intent = new Intent(INTENT_ACTION_COMPOSE); final Bundle bundle = new Bundle(); final List<String> mentions = new Extractor().extractMentionedScreennames(text_plain); mentions.remove(screen_name); mentions.add(0, screen_name); bundle.putStringArray(INTENT_KEY_MENTIONS, mentions.toArray(new String[mentions.size()])); bundle.putLong(INTENT_KEY_ACCOUNT_ID, mAccountId); bundle.putLong(INTENT_KEY_IN_REPLY_TO_ID, mStatusId); bundle.putString(INTENT_KEY_IN_REPLY_TO_TWEET, text_plain); bundle.putString(INTENT_KEY_IN_REPLY_TO_SCREEN_NAME, screen_name); bundle.putString(INTENT_KEY_IN_REPLY_TO_NAME, name); intent.putExtras(bundle); startActivity(intent); break; } case MENU_FAV: { if (mStatus.is_favorite) { mService.destroyFavorite(mAccountId, mStatusId); } else { mService.createFavorite(mAccountId, mStatusId); } break; } case MENU_COPY_CLIPBOARD: { final String textToCopy = "@" + mStatus.screen_name + ": " + mStatus.text_plain; int sdk = android.os.Build.VERSION.SDK_INT; if (sdk < android.os.Build.VERSION_CODES.HONEYCOMB) { android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getSystemService( Context.CLIPBOARD_SERVICE); clipboard.setText(textToCopy); } else { android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getSystemService( Context.CLIPBOARD_SERVICE); android.content.ClipData clip = android.content.ClipData.newPlainText("Status", textToCopy); clipboard.setPrimaryClip(clip); } Toast.makeText(getActivity(), R.string.text_copied, Toast.LENGTH_SHORT).show(); break; } case MENU_DELETE: { mService.destroyStatus(mAccountId, mStatusId); break; } case MENU_EXTENSIONS: { final Intent intent = new Intent(INTENT_ACTION_EXTENSION_OPEN_STATUS); final Bundle extras = new Bundle(); extras.putParcelable(INTENT_KEY_STATUS, mStatus); intent.putExtras(extras); startActivity(Intent.createChooser(intent, getString(R.string.open_with_extensions))); break; } case MENU_MUTE_SOURCE: { final String source = HtmlEscapeHelper.unescape(mStatus.source); if (source == null) return false; final Uri uri = Filters.Sources.CONTENT_URI; final ContentValues values = new ContentValues(); final SharedPreferences.Editor editor = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE).edit(); final ContentResolver resolver = getContentResolver(); values.put(Filters.TEXT, source); resolver.delete(uri, Filters.TEXT + " = '" + source + "'", null); resolver.insert(uri, values); editor.putBoolean(PREFERENCE_KEY_ENABLE_FILTER, true).commit(); Toast.makeText(getActivity(), getString(R.string.source_muted, source), Toast.LENGTH_SHORT).show(); break; } case MENU_SET_COLOR: { final Intent intent = new Intent(INTENT_ACTION_SET_COLOR); startActivityForResult(intent, REQUEST_SET_COLOR); break; } case MENU_CLEAR_COLOR: { clearUserColor(getActivity(), mStatus.user_id); updateUserColor(); break; } case MENU_RECENT_TWEETS: { openUserTimeline(getActivity(), mAccountId, mStatus.user_id, mStatus.screen_name); break; } case MENU_FIND_RETWEETS: { openUserRetweetedStatus(getActivity(), mStatus.account_id, mStatus.retweet_id > 0 ? mStatus.retweet_id : mStatus.status_id); break; } default: return false; } return super.onOptionsItemSelected(item); }
From source file:ca.rmen.android.scrumchatter.main.MainActivity.java
private void startFileChooser() { final Intent importIntent; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) importIntent = new Intent(Intent.ACTION_GET_CONTENT); else/*w w w. j a va 2 s . c o m*/ importIntent = new Intent(Intent.ACTION_OPEN_DOCUMENT); importIntent.setType("*/*"); importIntent.addCategory(Intent.CATEGORY_OPENABLE); startActivityForResult(Intent.createChooser(importIntent, getResources().getText(R.string.action_import)), ACTIVITY_REQUEST_CODE_IMPORT); }
From source file:com.dwdesign.tweetings.fragment.UserListDetailsFragment.java
@Override public boolean onMenuItemClick(final MenuItem item) { switch (item.getItemId()) { case MENU_FOLLOW: { if (mAccountId != mUserId) { if (mUserList.isFollowing()) { mService.destroyUserListSubscription(mAccountId, mUserList.getId()); } else { mService.createUserListSubscription(mAccountId, mUserList.getId()); }//from ww w .j ava 2 s . com } break; } case MENU_ADD: { final Bundle args = new Bundle(); args.putLong(INTENT_KEY_ACCOUNT_ID, mAccountId); args.putString(INTENT_KEY_TEXT, ""); args.putInt(INTENT_KEY_LIST_ID, mUserList.getId()); mAddMemberDialogFragment.setArguments(args); mAddMemberDialogFragment.show(getFragmentManager(), "add_member"); break; } case MENU_ADD_TAB: { CustomTabsAdapter mAdapter; mAdapter = new CustomTabsAdapter(getActivity()); ContentResolver mResolver; mResolver = getContentResolver(); final String tabName = mListName; final String tabType = AUTHORITY_LIST_TIMELINE; final String tabIcon = "list"; final long account_id = mAccountId; final String tabScreenName = mUserScreenName; final String tabListName = mListName; final String tabArguments = "{\"account_id\":" + account_id + ",\"screen_name\":\"" + tabScreenName + "\",\"list_name\":" + JSONObject.quote(tabListName) + "}"; final ContentValues values = new ContentValues(); values.put(Tabs.ARGUMENTS, tabArguments); values.put(Tabs.NAME, tabName); values.put(Tabs.POSITION, mAdapter.getCount()); values.put(Tabs.TYPE, tabType); values.put(Tabs.ICON, tabIcon); mResolver.insert(Tabs.CONTENT_URI, values); Toast.makeText(this.getActivity(), R.string.list_tab_added, Toast.LENGTH_SHORT).show(); break; } case MENU_DELETE: { if (mUserId != mAccountId) return false; mService.destroyUserList(mAccountId, mUserListId); break; } case MENU_EXTENSIONS: { final Intent intent = new Intent(INTENT_ACTION_EXTENSION_OPEN_USER_LIST); final Bundle extras = new Bundle(); extras.putParcelable(INTENT_KEY_USER_LIST, new ParcelableUserList(mUserList, mAccountId)); intent.putExtras(extras); startActivity(Intent.createChooser(intent, getString(R.string.open_with_extensions))); break; } } return true; }
From source file:com.sim2dial.dialer.ChatFragment.java
private void pickImage() { final List<Intent> cameraIntents = new ArrayList<Intent>(); final Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File file = new File(Environment.getExternalStorageDirectory(), getString(R.string.temp_photo_name)); imageToUploadUri = Uri.fromFile(file); captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageToUploadUri); cameraIntents.add(captureIntent);/*from www. ja v a2 s. c o m*/ final Intent galleryIntent = new Intent(); galleryIntent.setType("image/*"); galleryIntent.setAction(Intent.ACTION_GET_CONTENT); final Intent chooserIntent = Intent.createChooser(galleryIntent, getString(R.string.image_picker_title)); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[] {})); startActivityForResult(chooserIntent, ADD_PHOTO); }
From source file:com.android.cts.verifier.managedprovisioning.ByodHelperActivity.java
private void sendIntentInsideChooser(Intent toSend) { toSend.putExtra(CrossProfileTestActivity.EXTRA_STARTED_FROM_WORK, true); Intent chooser = Intent.createChooser(toSend, getResources().getString(R.string.provisioning_cross_profile_chooser)); startActivity(chooser);/*from w ww.j a v a2s . com*/ }
From source file:com.nttec.everychan.ui.gallery.GalleryActivity.java
private void share() { GalleryItemViewTag tag = getCurrentTag(); if (tag == null) return;//from w ww . j a v a2s. com Intent shareIntent = new Intent(Intent.ACTION_SEND); String extension = Attachments.getAttachmentExtention(tag.attachmentModel); switch (tag.attachmentModel.type) { case AttachmentModel.TYPE_IMAGE_GIF: shareIntent.setType("image/gif"); break; case AttachmentModel.TYPE_IMAGE_SVG: shareIntent.setType("image/svg+xml"); break; case AttachmentModel.TYPE_IMAGE_STATIC: if (extension.equalsIgnoreCase(".png")) { shareIntent.setType("image/png"); } else if (extension.equalsIgnoreCase(".jpg") || extension.equalsIgnoreCase(".jpg")) { shareIntent.setType("image/jpeg"); } else { shareIntent.setType("image/*"); } break; case AttachmentModel.TYPE_VIDEO: if (extension.equalsIgnoreCase(".mp4")) { shareIntent.setType("video/mp4"); } else if (extension.equalsIgnoreCase(".webm")) { shareIntent.setType("video/webm"); } else if (extension.equalsIgnoreCase(".avi")) { shareIntent.setType("video/avi"); } else if (extension.equalsIgnoreCase(".mov")) { shareIntent.setType("video/quicktime"); } else if (extension.equalsIgnoreCase(".mkv")) { shareIntent.setType("video/x-matroska"); } else if (extension.equalsIgnoreCase(".flv")) { shareIntent.setType("video/x-flv"); } else if (extension.equalsIgnoreCase(".wmv")) { shareIntent.setType("video/x-ms-wmv"); } else { shareIntent.setType("video/*"); } break; case AttachmentModel.TYPE_AUDIO: if (extension.equalsIgnoreCase(".mp3")) { shareIntent.setType("audio/mpeg"); } else if (extension.equalsIgnoreCase(".mp4")) { shareIntent.setType("audio/mp4"); } else if (extension.equalsIgnoreCase(".ogg")) { shareIntent.setType("audio/ogg"); } else if (extension.equalsIgnoreCase(".webm")) { shareIntent.setType("audio/webm"); } else if (extension.equalsIgnoreCase(".flac")) { shareIntent.setType("audio/flac"); } else if (extension.equalsIgnoreCase(".wav")) { shareIntent.setType("audio/vnd.wave"); } else { shareIntent.setType("audio/*"); } break; case AttachmentModel.TYPE_OTHER_FILE: shareIntent.setType("application/octet-stream"); break; } Logger.d(TAG, shareIntent.getType()); shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(tag.file)); startActivity(Intent.createChooser(shareIntent, getString(R.string.share_via))); }
From source file:com.andrew.apollo.ui.activities.AudioPlayerActivity.java
/** * /** Used to shared what the user is currently listening to *//* w w w .ja v a 2s.c o m*/ private void shareCurrentTrack() { if (MusicUtils.getTrackName() == null || MusicUtils.getArtistName() == null) { return; } final Intent shareIntent = new Intent(); final String shareMessage = getString(R.string.now_listening_to) + " " + MusicUtils.getTrackName() + " " + getString(R.string.by) + " " + MusicUtils.getArtistName() + " " + getString(R.string.hash_apollo); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_TEXT, shareMessage); startActivity(Intent.createChooser(shareIntent, getString(R.string.share_track_using))); }
From source file:com.nttec.everychan.ui.gallery.GalleryActivity.java
private void shareLink() { GalleryItemViewTag tag = getCurrentTag(); if (tag == null) return;//ww w . j a v a 2s . c o m String absoluteUrl = remote.getAbsoluteUrl(tag.attachmentModel.path); if (absoluteUrl == null) return; Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_SUBJECT, absoluteUrl); shareIntent.putExtra(Intent.EXTRA_TEXT, absoluteUrl); startActivity(Intent.createChooser(shareIntent, getString(R.string.share_via))); }
From source file:com.emergencyskills.doe.aed.UI.activity.TabsActivity.java
void init() { // img=(ImageView)findViewById(R.id.logo); TextView build = (TextView) findViewById(R.id.checkfornew); build.setOnClickListener(new View.OnClickListener() { @Override//from www. ja v a 2 s . c o m public void onClick(View v) { if (android.os.Build.VERSION.SDK_INT > 9) { StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); } CommonUtilities.logMe("about to check for version "); try { WebServiceHandler wsb = new WebServiceHandler(); ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>(); String result = wsb.getWebServiceData("http://doe.emergencyskills.com/api/version.php", postParameters); JSONObject jsonObject = new JSONObject(result); String version = jsonObject.getString("version"); String features = jsonObject.getString("features"); System.err.println("version is : " + version); if (!LoginActivity.myversion.equals(version)) { MyToast.popmessagelong( "There is a new build available. Please download for these features: " + features, TabsActivity.this); Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://vireo.org/esiapp")); browserIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); browserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(browserIntent); } else { MyToast.popmessagelong("You have the most current version!", TabsActivity.this); } } catch (Exception exc) { exc.printStackTrace(); } } }); TextView maillog = (TextView) findViewById(R.id.maillog); maillog.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final Dialog dialog = new Dialog(TabsActivity.this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.dialog_logout); TextView question = (TextView) dialog.findViewById(R.id.question); question.setText("Are you sure you want to email the log?"); TextView extra = (TextView) dialog.findViewById(R.id.extratext); extra.setText(""); dialog.getWindow().setBackgroundDrawable( new ColorDrawable(getResources().getColor(android.R.color.transparent))); Button yes = (Button) dialog.findViewById(R.id.yesbtn); yes.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(Intent.ACTION_SEND); i.setType("message/rfc822"); i.putExtra(Intent.EXTRA_EMAIL, new String[] { "rachelc@gmail.com" }); i.putExtra(Intent.EXTRA_SUBJECT, "Sending Log"); i.putExtra(Intent.EXTRA_TEXT, "body of email"); try { startActivity(Intent.createChooser(i, "Send mail...")); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(TabsActivity.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show(); } finish(); } }); Button no = (Button) dialog.findViewById(R.id.nobtn); no.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); ImageView close = (ImageView) dialog.findViewById(R.id.ivClose); close.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); dialog.show(); } }); listops listops = new listops(TabsActivity.this); CommonUtilities.logMe("logging in as: " + listops.getString("firstname")); TextView name = (TextView) findViewById(R.id.welcome); name.setText("Welcome, " + listops.getString("firstname")); TextView logoutname = (TextView) findViewById(R.id.logoutname); logoutname.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final Dialog dialog = new Dialog(TabsActivity.this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.dialog_logout); dialog.getWindow().setBackgroundDrawable( new ColorDrawable(getResources().getColor(android.R.color.transparent))); dialog.setContentView(R.layout.dialog_logout); Button yes = (Button) dialog.findViewById(R.id.yesbtn); yes.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { MyToast.popmessagelong("Logging out... ", TabsActivity.this); SharedPreferences prefs = getSharedPreferences("prefs", MODE_PRIVATE); SharedPreferences.Editor editor = prefs.edit(); editor.putString(Constants.loginkey, ""); editor.commit(); listops listops = new listops(TabsActivity.this); //make sure to remove the downloaded schools Intent intent = new Intent(TabsActivity.this, LoginActivity.class); startActivity(intent); ArrayList<Schoolinfomodel> ls = new ArrayList<Schoolinfomodel>(); listops.putdrilllist(ls); listops.putservicelist(ls); listops.putinstallllist(ls); ArrayList<PendingUploadModel> l = new ArrayList<PendingUploadModel>(); listops.putpendinglist(l); finish(); } }); Button no = (Button) dialog.findViewById(R.id.nobtn); no.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); ImageView close = (ImageView) dialog.findViewById(R.id.ivClose); close.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); dialog.show(); } }); ll1 = (LinearLayout) findViewById(R.id.ll1); ll2 = (LinearLayout) findViewById(R.id.ll2); ll3 = (LinearLayout) findViewById(R.id.ll3); ll4 = (LinearLayout) findViewById(R.id.ll4); ll5 = (LinearLayout) findViewById(R.id.ll5); ll6 = (LinearLayout) findViewById(R.id.ll6); ll1.setBackgroundColor(getResources().getColor(R.color.White)); llPickSchools = (LinearLayout) findViewById(R.id.llPickSchool); llDrills = (LinearLayout) findViewById(R.id.llDrills); llServiceCalls = (LinearLayout) findViewById(R.id.llServiceCalls); llNewInstalls = (LinearLayout) findViewById(R.id.llNewInstalls); llPendingUploads = (LinearLayout) findViewById(R.id.llPendingUploads); frameLayout = (FrameLayout) findViewById(R.id.frame); }
From source file:fi.mikuz.boarder.gui.DropboxMenu.java
@Override public boolean onMenuItemSelected(int featureId, MenuItem item) { switch (item.getItemId()) { case R.id.menu_share: Thread thread = new Thread() { public void run() { Looper.prepare();//from ww w .java 2s . com try { final ArrayList<String> boards = mCbla.getAllSelectedTitles(); if (!(mOperation == DOWNLOAD_OPERATION)) { mToastMessage = "Select 'Download' mode"; mHandler.post(mShowToast); } else if (boards.size() < 1) { mToastMessage = "Select boards to share"; mHandler.post(mShowToast); } else { String shareString = "I want to share some cool soundboards to you!\n\n" + "To use the boards you need to have Boarder for Android:\n" + ExternalIntent.mExtLinkMarket + "\n\n" + "Here are the boards:\n"; for (String board : boards) { shareString += board + " - " + mApi.createCopyRef("/" + board).copyRef + "\n"; } shareString += "\n\n" + "Importing a board:\n" + "1. Open Boarder'\n" + "2. Open Dropbox from menu in 'Soundboard Menu'\n" + "3. Open 'Import share' from menu\n" + "4. Copy a reference from above to textfield\n"; Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); sharingIntent.setType("text/plain"); sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Sharing boards"); sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareString); startActivity(Intent.createChooser(sharingIntent, "Share via")); } } catch (DropboxException e) { Log.e(TAG, "Unable to share", e); } } }; thread.start(); return true; case R.id.menu_import_share: LayoutInflater removeInflater = (LayoutInflater) DropboxMenu.this .getSystemService(LAYOUT_INFLATER_SERVICE); View importLayout = removeInflater.inflate(R.layout.dropbox_menu_alert_import_share, (ViewGroup) findViewById(R.id.alert_remove_sound_root)); AlertDialog.Builder importBuilder = new AlertDialog.Builder(DropboxMenu.this); importBuilder.setView(importLayout); importBuilder.setTitle("Import share"); final EditText importCodeInput = (EditText) importLayout.findViewById(R.id.importCodeInput); final EditText importNameInput = (EditText) importLayout.findViewById(R.id.importNameInput); importBuilder.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { t = new Thread() { public void run() { Looper.prepare(); try { mApi.addFromCopyRef(importCodeInput.getText().toString(), "/" + importNameInput.getText().toString()); mToastMessage = "Download the board from 'Download'"; mHandler.post(mShowToast); } catch (DropboxException e) { Log.e(TAG, "Unable to get shared board", e); } } }; t.start(); } }); importBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }); importBuilder.show(); return true; } return super.onMenuItemSelected(featureId, item); }