Example usage for android.content Intent ACTION_SEND

List of usage examples for android.content Intent ACTION_SEND

Introduction

In this page you can find the example usage for android.content Intent ACTION_SEND.

Prototype

String ACTION_SEND

To view the source code for android.content Intent ACTION_SEND.

Click Source Link

Document

Activity Action: Deliver some data to someone else.

Usage

From source file:com.phunkosis.gifstitch.helpers.ShareHelper.java

public static void startShareLinkIntent(Activity activity, String url) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.putExtra(Intent.EXTRA_TEXT, activity.getResources().getString(R.string.share_link_body) + " " + url);
    intent.putExtra(Intent.EXTRA_SUBJECT, activity.getResources().getString(R.string.share_link_subject));
    intent.setType("text/plain");
    activity.startActivity(Intent.createChooser(intent, "Share "));
}

From source file:ca.rmen.android.scrumchatter.export.Export.java

/**
 * Bring up the chooser to send the file.
 *//*from w  w w .j a  v a  2 s .  c  om*/
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:im.delight.android.baselib.Social.java

/**
 * Constructs an Intent for sharing/sending plain text and starts Activity chooser for that Intent
 *
 * @param context Context reference to start the Activity chooser from
 * @param windowTitle the string to be used as the window title for the Activity chooser
 * @param messageText the body text for the message to be shared
 * @param messageTitle the title/subject for the message to be shared, if supported by the target app
 *//* ww w  .j  a  v  a 2  s. co  m*/
public static void shareText(Context context, String windowTitle, String messageText, String messageTitle) {
    Intent intentInvite = new Intent(Intent.ACTION_SEND);
    intentInvite.setType(HTTP.PLAIN_TEXT_TYPE);
    intentInvite.putExtra(Intent.EXTRA_SUBJECT, messageTitle);
    intentInvite.putExtra(Intent.EXTRA_TEXT, messageText);
    context.startActivity(Intent.createChooser(intentInvite, windowTitle));
}

From source file:com.activiti.android.platform.intent.IntentUtils.java

/**
 * Allow to send a link to other application installed in the device.
 *
 * @param fr//  w w  w  . j  a v a2s . co m
 * @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//w w  w .  j  a v  a 2s. com
 * @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.google.android.apps.chrometophone.ShareLinkActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (Intent.ACTION_SEND.equals(getIntent().getAction())) {
        String text = getIntent().getExtras().getString(Intent.EXTRA_TEXT);
        Pattern regex = Pattern.compile("http(s)?://.*"); // find the link
        Matcher matcher = regex.matcher(text);
        if (matcher.find()) {
            mPendingAuth = false;//  w w  w.j a  va2  s.  c o  m
            mPendingLink = matcher.group();
            sendLink();
        }
    }
}

From source file:net.quranquiz.ui.QQLastScreenActivity.java

private Intent createShareIntent() {
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.setType("text/plain");
    //shareIntent.putExtra(Intent.EXTRA_SUBJECT, "  ?  ");
    shareIntent.putExtra(Intent.EXTRA_TEXT, conclusionMessage + " http://quranquiz.net");
    return shareIntent;
}

From source file:com.app.common.util.IntentUtils.java

public static void startEmailActivity(Context context, String to, String subject, String body) {
    final Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("message/rfc822");

    if (!TextUtils.isEmpty(to)) {
        intent.putExtra(Intent.EXTRA_EMAIL, new String[] { to });
    }/* w w  w  .  j  av  a2s .c  o m*/
    if (!TextUtils.isEmpty(subject)) {
        intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    }
    if (!TextUtils.isEmpty(body)) {
        intent.putExtra(Intent.EXTRA_TEXT, body);
    }

    final PackageManager pm = (PackageManager) context.getPackageManager();
    try {
        if (pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY).size() == 0) {
            intent.setType("text/plain");
        }
    } catch (Exception e) {
        Log.w("Exception encountered while looking for email intent receiver.", e);
    }

    context.startActivity(intent);
}

From source file:com.github.longkai.zhihu.util.Utils.java

/**
 * ??//ww  w.  ja  v a 2 s.  c om
 * @param context
 * @param subject 
 * @param content 
 * @return intent
 */
public static Intent share(Context context, String subject, String content) {
    Intent share = new Intent(Intent.ACTION_SEND);
    share.setType("text/plain");
    share.putExtra(Intent.EXTRA_SUBJECT, subject);
    share.putExtra(Intent.EXTRA_TEXT, content + context.getString(R.string.share_from));
    return share;
}

From source file:cc.softwarefactory.lokki.android.fragments.AboutFragment.java

private void openTellAFriendActivity() {
    try {//from  ww 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");
    }
}