安卓学习小程序报错,
Intent intent = new Intent();
intent.setAction(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel://18515466306"));
startActivity(intent);
error:
java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.CALL dat=tel:xxxxxxxxxxxxx cmp=com.android.server.telecom/.CallActivity } from ProcessRecord{578eb40 27997:com.example.yjsong.helloworld/u0a20} (pid=27997, uid=10020) requires android.permission.CALL_PHONE
解决办法:添加程序的打电话权限:
<uses-permission android:name="android.permission.CALL_PHONE" />
短信权限
<uses-permission android:name="android.permission.SEND_SMS"/>