android中调用系统的发送短信、发送邮件、打电话功能

时间:2022-11-10 13:53:01

1 调用发送短信功能:

Uri smsToUri = Uri.parse("smsto:"); 
Intent sendIntent = new Intent(Intent.ACTION_VIEW, smsToUri); 
 sendIntent.putExtra("address", "123456"); //电话号码,这行去掉的话,默认就没有电话
sendIntent.putExtra("sms_body","短信内容"); 
sendIntent.setType("vnd.android-dir/mms-sms"); 
startActivity(sendIntent);
 
2 调用发送邮件功能: 
Intent email = new Intent(android.content.Intent.ACTION_SEND);
email.setType("plain/text");
String[] emailReciver = new String[]{"xxxx@qq.com","yyy@xx.com"};
 
String  emailSubject = "从问道分享来的文章";
StringemailBody = internetpath;
//设置邮件默认地址
email.putExtra(android.content.Intent.EXTRA_EMAIL, emailReciver);
//设置邮件默认标题
email.putExtra(android.content.Intent.EXTRA_SUBJECT, emailSubject);
//设置要默认发送的内容
email.putExtra(android.content.Intent.EXTRA_TEXT, emailBody);
//调用系统的邮件系统
startActivity(Intent.createChooser(email, "请选择邮件发送软件"));
 
3.打电话
 Intent intent = new Intent();
 intent.setAction("android.intent.action.DIAL");
 intent.setData(Uri.parse("tel:400 616 0066"));
 startActivity(intent);
 
  <uses-permission android:name="android.permission.CALL_PHONE"/>
  <uses-permission android:name="android.permission.SEND_SMS"/>