Android 打电话发短信代码
打电话发短信的功能.
//发短信 class SendMsgClickListener implements OnClickListener { public void onClick(View v) { //调用Android系统API发送短信 Uri uri = Uri.parse("smsto:15800001234"); Intent intent = new Intent(Intent.ACTION_SENDTO, uri); intent.putExtra("sms_body", "android..."); startActivity(intent); } } //打电话 class SendCallClickListener implements OnClickListener {iphone5 public void onClick(View v) { //调用Android系统API打电话 Uri uri = Uri.parse("tel:15800001234"); Intent intent = new Intent(Intent.ACTION_CALL, uri); startActivity(intent); } }
要授权的,需要在AndroidManifest.xml中加入两行配置
<uses-permission android:name="android.permission.CALL_PHONE" /> <uses-permission android:name="android.permission.SEND_SMS"/>