public class SmsUtil {
public static void sendSms(Context context, String number, String body) {
String uri = null;
if (TextUtils.isEmpty(number)) {
uri = "smsto:";
} else {
Pattern p = Pattern.compile("[0-9]*");
Matcher m = p.matcher(number);
if (m.matches()) {
uri = "smsto:" + number;
} else {
uri = "smsto:";
}
}
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse(uri));
intent.putExtra("sms_body", body);
intent.putExtra("compose_mode", true);
context.startActivity(intent);
}
// 发送短信
public static void sendSms2(Context context, String number, String body) {
Intent it = new Intent(Intent.ACTION_VIEW);
it.putExtra("sms_body", body);
it.putExtra("address", number);
it.setType("vnd.android-dir/mms-sms");
context.startActivity(it);
}
// main
public static void managerSms(Context context) { // DefaultSettingActivity
Intent mmsIntent = new Intent(Intent.ACTION_MAIN);
mmsIntent.addCategory(Intent.CATEGORY_DEFAULT);
mmsIntent.setType("vnd.android-dir/mms-sms");
context.startActivity(mmsIntent);
}
}
http://blog.sina.com.cn/s/blog_7b18d5340100xohl.html