List of usage examples for android.content Intent createChooser
public static Intent createChooser(Intent target, CharSequence title)
From source file:com.activiti.android.platform.intent.IntentUtils.java
/** * Allow to send a link to other application installed in the device. * * @param fr//from w w w . ja v a2 s . com * @param url */ public static void actionShareLink(Fragment fr, String title, String url) { try { Intent i = new Intent(Intent.ACTION_SEND); i.setType("text/plain"); i.putExtra(Intent.EXTRA_SUBJECT, title); i.putExtra(Intent.EXTRA_TEXT, url); fr.startActivity(Intent.createChooser(i, fr.getActivity().getText(R.string.task_action_share_link))); } catch (ActivityNotFoundException e) { } }
From source file:im.delight.android.commons.Social.java
/** * Displays an application chooser and shares the specified plain text and subject line using the selected application * * @param context a context reference/*from w ww . j a v a 2 s . c o m*/ * @param windowTitle the title for the application chooser's window * @param bodyTextToShare the body text to be shared * @param subjectTextToShare the title or subject for the message to be shared, if supported by the target application */ public static void shareText(final Context context, final String windowTitle, final String bodyTextToShare, final String subjectTextToShare) { final Intent intentInvite = new Intent(Intent.ACTION_SEND); intentInvite.setType(HTTP.PLAIN_TEXT_TYPE); intentInvite.putExtra(Intent.EXTRA_SUBJECT, subjectTextToShare); intentInvite.putExtra(Intent.EXTRA_TEXT, bodyTextToShare); context.startActivity(Intent.createChooser(intentInvite, windowTitle)); }
From source file:com.manning.androidhacks.hack035.MainActivity.java
public void onTakePicture(View v) { Intent takePhotoIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); Intent chooserIntent = Intent.createChooser(takePhotoIntent, getString(R.string.activity_main_pick_picture)); startActivityForResult(chooserIntent, TAKE_PICTURE); }
From source file:ca.rmen.android.scrumchatter.export.Export.java
/** * Bring up the chooser to send the file. *///from w w w.j a va2 s . c o m static void share(Context context, File file, String mimeType) { Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.export_message_subject)); sendIntent.putExtra(Intent.EXTRA_TEXT, context.getString(R.string.export_message_body)); Uri uri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".fileprovider", file); sendIntent.putExtra(Intent.EXTRA_STREAM, uri); sendIntent.setType(mimeType); if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) { List<ResolveInfo> resInfoList = context.getPackageManager().queryIntentActivities(sendIntent, PackageManager.MATCH_DEFAULT_ONLY); for (ResolveInfo resolveInfo : resInfoList) { String packageName = resolveInfo.activityInfo.packageName; context.grantUriPermission(packageName, uri, Intent.FLAG_GRANT_READ_URI_PERMISSION); Log.v(TAG, "grant permission to " + packageName); } } context.startActivity( Intent.createChooser(sendIntent, context.getResources().getText(R.string.action_share))); }
From source file:cc.softwarefactory.lokki.android.fragments.AboutFragment.java
private void openTellAFriendActivity() { try {// w w w . j a v a 2 s . co m Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.share_subject)); intent.putExtra(Intent.EXTRA_TEXT, getString(R.string.share_text)); startActivity(Intent.createChooser(intent, getString(R.string.share))); } catch (ActivityNotFoundException e) { Log.e(TAG, "Couldn't open 'tell a friend about lokki' activity"); } }
From source file:com.galois.qrstream.lib.DecodeThread.java
@Override public void run() { Job message;/* ww w . jav a 2 s .c o m*/ try { message = (Job) receiver.decodeQRSerializable(cameraManager); Log.w(Constants.APP_TAG, "DecodeThread received " + message.getData().length + " bytes, " + "mimetype: " + message.getMimeType()); Intent i = buildIntent(message); context.startActivity(Intent.createChooser(i, "Open with")); } catch (ReceiveException e) { Log.e(Constants.APP_TAG, "DecodeThread failed to read message. " + e.getMessage()); } catch (IOException e) { Log.e(Constants.APP_TAG, "Could not store data to temp file." + e.getMessage()); } finally { // The receiver has finished. Clear the UI. uiHandle.sendMessage(new Message()); } }
From source file:at.jclehner.appopsxposed.BugReportBuilder.java
public static void buildAndSend(final Context context) { if (!SU.available()) { Toast.makeText(context, R.string.toast_needs_root, Toast.LENGTH_SHORT).show(); return;/* w w w .j a v a2s. c om*/ } Toast.makeText(context, R.string.building_toast, Toast.LENGTH_LONG).show(); final BugReportBuilder brb = new BugReportBuilder(context); new AsyncTask<Void, Void, Uri>() { @Override protected Uri doInBackground(Void... params) { return brb.build(); } @Override protected void onPostExecute(Uri result) { final ArrayList<Parcelable> uris = new ArrayList<Parcelable>(); uris.add(result); final Intent target = new Intent(Intent.ACTION_SEND_MULTIPLE); target.setType("text/plain"); target.putExtra(Intent.EXTRA_SUBJECT, "[REPORT][AppOpsXposed " + Util.getAoxVersion(context) + "] " + Build.FINGERPRINT); target.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); //target.putExtra(Intent.EXTRA_STREAM, result); target.putExtra(Intent.EXTRA_TEXT, "!!! BUG REPORTS WITHOUT ADDITIONAL INFO WILL BE IGNORED !!!"); //target.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); final Intent intent = Intent.createChooser(target, null); //intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); context.startActivity(intent); } }.execute(); }
From source file:com.manning.androidhacks.hack035.MainActivity.java
public void onPickPicture(View v) { Intent pickIntent = new Intent(Intent.ACTION_GET_CONTENT); pickIntent.setType("image/*"); Intent chooserIntent = Intent.createChooser(pickIntent, getString(R.string.activity_main_take_picture)); startActivityForResult(chooserIntent, PICK_PICTURE); }
From source file:com.burhan.udacity.popularmovies.ui.helper.MoviesHelper.java
public void shareTrailer(int messageTemplateResId, Video video) { mActivity.startActivity(/*w ww .j a v a 2s .c o m*/ Intent.createChooser(createShareIntent(messageTemplateResId, video.getName(), video.getKey()), mActivity.getString(R.string.title_share_trailer))); }
From source file:org.geek.utils.ApplicationUtils.java
/** * Share a page.//from w w w. j ava 2 s.com * @param activity The parent activity. * @param title The page title. * @param url The page url. */ public static void sharePage(Activity activity, String title, String url) { Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_TEXT, url); shareIntent.putExtra(Intent.EXTRA_SUBJECT, title); try { activity.startActivity( Intent.createChooser(shareIntent, activity.getString(R.string.Main_ShareChooserTitle))); } catch (android.content.ActivityNotFoundException ex) { // if no app handles it, do nothing } }