love li fang fang forever

Android系统发短信打电话发邮件代码

• _posts

迁移源地址为:《Android系统发短信打电话发邮件代码》

1.权限配置:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.WRITE_SMS" />
<uses-permission android:name="android.permission.CAMERA" />

2.java代码

contacts_call.setOnClickListener(new View.OnClickListener() {

@Override public void onClick(View v) { Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse(“tel:”+int_number)); startActivity(callIntent);

// Toast.makeText(getApplicationContext(), “我的电话:”+number, Toast.LENGTH_LONG).show(); } }); contacts_duanxin.setOnClickListener(new View.OnClickListener() {

@Override public void onClick(View v) { Uri smsToUri = Uri.parse(“smsto:”+int_number);// 联系人地址 Intent mIntent = new Intent(android.content.Intent.ACTION_SENDTO,smsToUri); mIntent.putExtra(“sms_body”, “输入短信内容”);// 短信的内容 startActivity(mIntent); } }); contacts_email.setOnClickListener(new View.OnClickListener() {

@Override public void onClick(View v) { Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); //设置文本格式 emailIntent.setType(“text/plain”); //设置对方邮件地址 emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, “”); //设置标题内容 emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,getString(R.string.setting_recommend_words)); //设置邮件文本内容 emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,getString(R.string.setting_recommend_words)); startActivity(Intent.createChooser(emailIntent,”Choose Email Client”));

} });