List of usage examples for android.content Intent createChooser
public static Intent createChooser(Intent target, CharSequence title)
From source file:de.jamoo.muzei.WallSource.java
@Override public void onCustomCommand(int id) { super.onCustomCommand(id); if (id == COMMAND_ID_SHARE) { Artwork currentArtwork = getCurrentArtwork(); Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); Uri artUrl = currentArtwork.getImageUri(); if (DEBUG) Log.d(TAG, "artUrl: " + artUrl); String author = currentArtwork.getByline(); if (DEBUG) Log.d(TAG, "author: " + author); String playUrl = "http://play.google.com/store/apps/details?id=" + getPackageName(); if (DEBUG) Log.d(TAG, "playUrl: " + playUrl); shareIntent.putExtra(Intent.EXTRA_TEXT, "My wallpaper today is " + currentArtwork.getTitle() + " by " + author + " \n" + artUrl + " \n" + "from the " + getString(R.string.app_name) + " app\n" + "Get it now on the PlayStore! " + playUrl); shareIntent = Intent.createChooser(shareIntent, "Share Wallpaper"); shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(shareIntent);//from www. j a va2 s. c o m } }
From source file:com.gelecekonline.android.uploadornek.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); selectedImageView = (ImageView) findViewById(R.id.selectedImageView); selectImageButton = (Button) findViewById(R.id.selectImageButton); selectImageButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { try { //Resim secen Intent tanimlamasi Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, getString(R.string.select_image)), SELECT_IMAGE_INTENT_ID); } catch (Exception e) { Toast.makeText(getApplicationContext(), getString(R.string.select_image_problem), Toast.LENGTH_LONG).show(); }//w ww . j a v a 2 s .c o m } }); uploadButton = (Button) findViewById(R.id.uploadButton); uploadButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (selectedImageView.getDrawable() == null) { Toast.makeText(getApplicationContext(), getString(R.string.please_select_image), Toast.LENGTH_LONG).show(); } else { dialog = ProgressDialog.show(MainActivity.this, getString(R.string.image_uploading), getString(R.string.please_wait), true); if (uploadImageTask == null || uploadImageTask.getStatus() == AsyncTask.Status.FINISHED) { uploadImageTask = new UploadImageTask(); } uploadImageTask.execute(); } } }); }
From source file:im.delight.android.commons.Social.java
/** * Displays an application chooser and shares the specified file using the selected application * * @param context a context reference//w ww . java 2 s . c om * @param windowTitle the title for the application chooser's window * @param fileToShare the file to be shared * @param mimeTypeForFile the MIME type for the file to be shared (e.g. `image/jpeg`) * @param subjectTextToShare the message title or subject for the file, if supported by the target application */ public static void shareFile(final Context context, final String windowTitle, final File fileToShare, final String mimeTypeForFile, final String subjectTextToShare) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setType(mimeTypeForFile); intent.putExtra(Intent.EXTRA_SUBJECT, subjectTextToShare); intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(fileToShare)); context.startActivity(Intent.createChooser(intent, windowTitle)); }
From source file:com.allen.mediautil.ImageTakerHelper.java
/** * ? onActivityResult()?/* w w w .j a va 2 s . c o m*/ */ public static void openAlbum(Fragment fragment) { Intent intentAlbum = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); intentAlbum.setType(MEDIA_TYPE_IMAGE); fragment.startActivityForResult(Intent.createChooser(intentAlbum, ""), REQUEST_ALBUM); }
From source file:net.bible.android.control.page.PageControl.java
/** send the current verse via social applications installed on user's device *///from w w w. j av a 2s.com public void shareVerse() { try { Book book = getCurrentPageManager().getCurrentPage().getCurrentDocument(); Key key = getCurrentPageManager().getCurrentPage().getSingleKey(); String text = key.getName() + "\n" + SwordContentFacade.getInstance().getCanonicalText(book, key); Intent sendIntent = new Intent(Intent.ACTION_SEND); sendIntent.setType("text/plain"); sendIntent.putExtra(Intent.EXTRA_TEXT, text); // subject is used when user chooses to send verse via e-mail sendIntent.putExtra(Intent.EXTRA_SUBJECT, BibleApplication.getApplication().getText(R.string.share_verse_subject)); Activity activity = CurrentActivityHolder.getInstance().getCurrentActivity(); activity.startActivity(Intent.createChooser(sendIntent, activity.getString(R.string.share_verse))); } catch (Exception e) { Log.e(TAG, "Error sharing verse", e); Dialogs.getInstance().showErrorMsg("Error sharing verse"); } }
From source file:com.bellman.bible.android.control.page.PageControl.java
/** send the current verse via social applications installed on user's device *//*from ww w. j a va 2 s . c o m*/ public void shareVerse(VerseRange verseRange) { try { Book book = getCurrentPageManager().getCurrentPage().getCurrentDocument(); String text = verseRange.getName() + "\n" + SwordContentFacade.getInstance().getCanonicalText(book, verseRange); Intent sendIntent = new Intent(Intent.ACTION_SEND); sendIntent.setType("text/plain"); sendIntent.putExtra(Intent.EXTRA_TEXT, text); // subject is used when user chooses to send verse via e-mail sendIntent.putExtra(Intent.EXTRA_SUBJECT, CurrentActivityHolder.getInstance().getApplication().getText(R.string.share_verse_subject)); Activity activity = CurrentActivityHolder.getInstance().getCurrentActivity(); activity.startActivity(Intent.createChooser(sendIntent, activity.getString(R.string.share_verse))); } catch (Exception e) { Log.e(TAG, "Error sharing verse", e); Dialogs.getInstance().showErrorMsg("Error sharing verse"); } }
From source file:codepath.watsiapp.fragments.DonateShareFragment.java
private void startShareIntent() { Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_TEXT, patientProfileUrl); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Fund Treatment"); startActivity(Intent.createChooser(shareIntent, "Share Story")); }
From source file:com.wodify.cordova.plugin.filepicker.FilePicker.java
/** * Pick file from device./* w ww .j a v a2 s .c o m*/ */ public void pickFile() { Intent intent = new Intent(); // Any type of file may be picked intent.setType("*/*"); intent.setAction(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); if (this.cordova != null) { this.cordova.startActivityForResult((CordovaPlugin) this, Intent.createChooser(intent, "Pick File"), 0); } }
From source file:jahirfiquitiva.iconshowcase.services.MuzeiArtSourceService.java
@Override public void onCustomCommand(int id) { super.onCustomCommand(id); if (id == COMMAND_ID_SHARE) { Artwork currentArtwork = getCurrentArtwork(); Intent shareWall = new Intent(Intent.ACTION_SEND); shareWall.setType("text/plain"); String wallName = currentArtwork.getTitle(); String authorName = currentArtwork.getByline(); String storeUrl = MARKET_URL + getPackageName(); String iconPackName = getString(R.string.app_name); shareWall.putExtra(Intent.EXTRA_TEXT, getString(R.string.share_text, wallName, authorName, iconPackName, storeUrl)); shareWall = Intent.createChooser(shareWall, getString(R.string.share_title)); shareWall.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(shareWall);/*w w w . j a v a 2 s .c om*/ } }
From source file:com.cerema.cloud2.ui.dialog.UploadSourceDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { String[] allTheItems = { getString(R.string.actionbar_upload_files), getString(R.string.actionbar_upload_from_apps) }; AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.actionbar_upload); builder.setItems(allTheItems, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { if (item == 0) { Intent action = new Intent(getActivity(), UploadFilesActivity.class); action.putExtra(UploadFilesActivity.EXTRA_ACCOUNT, ((FileActivity) getActivity()).getAccount()); //startActivityForResult(action, ACTION_SELECT_MULTIPLE_FILES); // this flow seems broken; // Actionbarsherlock, maybe? getActivity().startActivityForResult(action, FileDisplayActivity.ACTION_SELECT_MULTIPLE_FILES); } else if (item == 1) { Intent action = new Intent(Intent.ACTION_GET_CONTENT); action = action.setType("*/*").addCategory(Intent.CATEGORY_OPENABLE); //Intent.EXTRA_ALLOW_MULTIPLE is only supported on api level 18+, Jelly Bean if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { action.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); }//w ww . j av a 2s. c o m getActivity().startActivityForResult( Intent.createChooser(action, getString(R.string.upload_chooser_title)), FileDisplayActivity.ACTION_SELECT_CONTENT_FROM_APPS); } } }); return builder.create(); }