@Override public boolean onPreferenceClick(Preference preference) { Intent intent = ShareCompat.IntentBuilder.from(activity).setChooserTitle (activity.getString(R.string.send_test_intent_chooser_title)).setType(activity .getString(R.string.mime_type_text_plain)) .setText(activity.getString(R.string.send_test_intent_content)).createChooserIntent(); activity.startActivity(intent); return true; } });
/** * Set the title that will be used for the activity chooser for this share. * * @param resId Resource ID of the title string to use * @return This IntentBuilder for method chaining */ public IntentBuilder setChooserTitle(@StringRes int resId) { return setChooserTitle(mActivity.getText(resId)); }
.setText(shareText) .setType("text/plain") .setChooserTitle("Share FireFiles") .startChooser(); AnalyticsManager.logEvent("app_share");
/** * Handles the onClick for the "Share This Text" button. The * implicit intent here is created by the {@link ShareCompat.IntentBuilder} * class. An app chooser appears with the available options for sharing. * * ShareCompat.IntentBuilder is from the v4 Support Library. * * @param view The view (Button) that was clicked. */ public void shareText(View view) { String txt = mShareTextEditText.getText().toString(); String mimeType = "text/plain"; ShareCompat.IntentBuilder .from(this) .setType(mimeType) .setChooserTitle(R.string.share_text_with) .setText(txt) .startChooser(); } }
/** * Creates an intent to prompt the user for sharing text. * * @param title The name of the text being stored. * @param url The url to be shared. * @param activity The current activity. */ public static Intent shareText(String title, String url, Activity activity) { return ShareCompat.IntentBuilder.from(activity) .setSubject(title) .setText(url) .setStream(Uri.parse(url)) .setType(TEXT_PLAIN_MIME) .setChooserTitle(R.string.share) .getIntent(); }
private void shareText (String text) { // COMPLETED (2) Create a String variable called mimeType and set it to "text/plain" String mimeType = "text/plain"; // COMPLETED (3) Create a title for the chooser window that will pop up String title = "Share with:"; // COMPLETED (4) Use ShareCompat.IntentBuilder to build the Intent and start the chooser ShareCompat.IntentBuilder .from(this) .setType(mimeType) .setChooserTitle(title) .setText(text) .startChooser(); } }
public static void openFeedback(Activity activity){ ShareCompat.IntentBuilder .from(activity) .setEmailTo(new String[]{"gigabytedevelopers@gmail.com"}) .setSubject("FireFiles Feedback" + getSuffix()) .setType("text/email") .setChooserTitle("Send Feedback") .startChooser(); }
/** * Set the title that will be used for the activity chooser for this share. * * @param resId Resource ID of the title string to use * @return This IntentBuilder for method chaining */ public IntentBuilder setChooserTitle(int resId) { return setChooserTitle(mActivity.getText(resId)); }
public static void sharePlainText(Activity activity, String textToShare) { ShareCompat.IntentBuilder .from(activity) .setText(textToShare) .setType("text/plain") .setChooserTitle(activity.getString(R.string.share_using)) .startChooser(); }
.setChooserTitle(title) .setText(textToShare) .startChooser();