Example usage for android.content Intent ACTION_SENDTO

List of usage examples for android.content Intent ACTION_SENDTO

Introduction

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

Prototype

String ACTION_SENDTO

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

Click Source Link

Document

Activity Action: Send a message to someone specified by the data.

Usage

From source file:Main.java

public static void sendFeedback2(Context context) {

    String versionName = "";

    try {// w  w  w . j av a 2  s  .  co m

        versionName = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;

    } catch (NameNotFoundException e) {

        e.printStackTrace();
    }

    StringBuffer sb = new StringBuffer();
    sb.append("We would like to hear your feedback and improvement ideas. Please feel free to share below :")
            .append("\r\n").append("\r\n").append("\r\n").append("Attach Screenshots (if any) : ")
            .append("\r\n").append("\r\n").append("\r\n").append("Running on ").append(android.os.Build.MODEL)
            .append("\r\n").append("OS Version : ").append(android.os.Build.VERSION.RELEASE).append("\r\n")
            .append("Client Version : ").append(versionName);

    Intent emailIntent = new Intent(Intent.ACTION_SENDTO,
            Uri.fromParts("mailto", "messageplus_feedback@starhub.com", null));
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Message+ - Feedback");
    emailIntent.putExtra(Intent.EXTRA_TEXT, sb.toString());
    context.startActivity(Intent.createChooser(emailIntent, "Choose email client"));

}

From source file:Main.java

/** Checks if the device can send SMS messages.
 *
 * @param context Context for obtaining the package manager.
 * @return true if you can send SMS, false otherwise.
 *///from w  ww.  j  a  v  a2s . c  o m
public static boolean canSendSms(Context context) {
    Uri smsUri = Uri.parse("smsto:12345");
    Intent smsIntent = new Intent(Intent.ACTION_SENDTO, smsUri);
    PackageManager smspackageManager = context.getPackageManager();
    List<ResolveInfo> smsresolveInfos = smspackageManager.queryIntentActivities(smsIntent, 0);
    return smsresolveInfos.size() > 0;
}

From source file:Main.java

/** Checks if the device can send SMS messages.
 *
 * @param context Context for obtaining the package manager.
 * @return true if you can send SMS, false otherwise.
 *//*from www.  j a va  2s. c  om*/
public static boolean canSendSms(Context context) {
    Uri smsUri = Uri.parse("smsto:12345");
    Intent smsIntent = new Intent(Intent.ACTION_SENDTO, smsUri);
    PackageManager smspackageManager = context.getPackageManager();
    List<ResolveInfo> smsresolveInfos = smspackageManager.queryIntentActivities(smsIntent, 0);
    if (smsresolveInfos.size() > 0) {
        return true;
    } else {
        return false;
    }
}

From source file:com.jay.util.PhoneUtil.java

/**
 * ??//  w ww.j  a  va  2 s .  c om
 *
 * @param activity    Activity
 * @param phoneNumber ??
 */
public static void sendMessage(Context activity, String phoneNumber) {
    Uri uri = Uri.parse("smsto:" + phoneNumber);
    Intent it = new Intent(Intent.ACTION_SENDTO, uri);
    it.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    activity.startActivity(it);

}

From source file:Main.java

/**
 * Find out if K-9 Mail is enabled, i.e. an account was set up.
 *
 * @param context//w  ww  .  ja  v  a 2  s .co m
 *         Used to retrieve the package manager.
 *
 * @return {@code true} if K-9 Mail is enabled, {@code false} otherwise.
 */
public static final boolean isK9Enabled(Context context) {
    PackageManager manager = context.getPackageManager();
    try {
        Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:"));
        intent.setPackage(PACKAGE_NAME);
        List<ResolveInfo> results = manager.queryIntentActivities(intent, 0);
        return (results != null && results.size() > 0);
    } catch (Exception e) {
        return false;
    }
}

From source file:Main.java

/** Launch a SMS intent if the device is capable.
 *
 * @param activity The parent activity (for context)
 * @param number The number to sms (not the full URI)
 * @param text The sms body// w  w  w .  j  av a 2 s  .  c o m
 */
public static void launchSmsIntent(final Activity activity, String number, String text) {
    Log.i(LOG_TAG, "Launch SMS intent to " + number);
    // create sms intent
    Uri smsUri = Uri.parse("smsto:" + number);
    Intent smsIntent = new Intent(Intent.ACTION_SENDTO, smsUri);
    smsIntent.putExtra("sms_body", text);
    // make sure there is an activity which can handle the intent.
    PackageManager smspackageManager = activity.getPackageManager();
    List<ResolveInfo> smsresolveInfos = smspackageManager.queryIntentActivities(smsIntent, 0);
    if (smsresolveInfos.size() > 0) {
        activity.startActivity(smsIntent);
    }
}

From source file:com.github.akinaru.rfdroid.menu.MenuUtils.java

/**
 * Execute actions according to selected menu item
 *
 * @param menuItem MenuItem object//  w  w  w .  j  a  v a  2s .  c  om
 * @param mDrawer  navigation drawer
 * @param context  android context
 */
public static void selectDrawerItem(MenuItem menuItem, DrawerLayout mDrawer, Context context) {

    switch (menuItem.getItemId()) {
    case R.id.switch_chart_data: {
        break;
    }
    case R.id.report_bugs: {
        Intent intent = new Intent(Intent.ACTION_SENDTO,
                Uri.fromParts("mailto", "kiruazoldik92@gmail.com", null));
        intent.putExtra(Intent.EXTRA_SUBJECT, "RFdroid Issue");
        intent.putExtra(Intent.EXTRA_TEXT, "Your error report here...");
        context.startActivity(Intent.createChooser(intent, "Report a problem"));
        break;
    }
    case R.id.open_source_components: {
        OpenSourceItemsDialog d = new OpenSourceItemsDialog(context);
        d.show();
        break;
    }
    case R.id.about_app: {
        AboutDialog dialog = new AboutDialog(context);
        dialog.show();
        break;
    }
    }
    mDrawer.closeDrawers();
}

From source file:am.project.x.utils.ContextUtils.java

/**
 * ???//from w ww . j a va 2s. co  m
 *
 * @param context    Context
 * @param subject    
 * @param attachment 
 * @param addresses  ?
 */
public static void sendEmail(Context context, @Nullable String subject, @Nullable Uri attachment,
        String... addresses) {
    Intent intent = new Intent(Intent.ACTION_SENDTO);
    intent.setData(Uri.parse("mailto:"));
    intent.putExtra(Intent.EXTRA_EMAIL, addresses);
    if (subject != null)
        intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    if (attachment != null)
        intent.putExtra(Intent.EXTRA_STREAM, attachment);
    if (intent.resolveActivity(context.getPackageManager()) != null) {
        context.startActivity(intent);
    }
}

From source file:com.ox.utils.IntentUtils.java

/**
 * send email/*  w  w w  . jav  a  2 s .  co m*/
 *
 * @param email email address
 */
public static void sendEmail(Context context, String email) {
    Intent data = new Intent(Intent.ACTION_SENDTO);
    data.setData(Uri.parse("mailto:" + email));
    data.putExtra(Intent.EXTRA_SUBJECT, "[ " + AppUtils.getApplicationName(context) + " ] " + "??");
    ComponentName componentName = data.resolveActivity(context.getPackageManager());
    if (componentName != null) {
        context.startActivity(data);
    } else {
        Toast.makeText(context, "", Toast.LENGTH_SHORT).show();
    }
}

From source file:com.hch.beautyenjoy.tools.IntentUtils.java

/**
 * send email// w w  w .j a va2  s  . co  m
 *
 * @param email email address
 */
public static void sendEmail(Context context, String email) {
    Intent data = new Intent(Intent.ACTION_SENDTO);
    data.setData(Uri.parse("mailto:" + email));
    data.putExtra(Intent.EXTRA_SUBJECT, "[ " + AppTools.getApplicationName(context) + " ] " + "??");
    ComponentName componentName = data.resolveActivity(context.getPackageManager());
    if (componentName != null) {
        context.startActivity(data);
    } else {
        Toast.makeText(context, "", Toast.LENGTH_SHORT).show();
    }
}