Android 9.0 关于ACTION_CALL无权限导致闪退的问题
18年年底毕业,开始从事android研发,对application层有兴趣,于是自学使用Android studio对app的简单开发。其实上学的时候学了一点用eclipse实现的UI设计,不过现在用着studio,就是 真香。
人生第一篇的博文,废话不多说,切入主题。
学习到用Intent启用程序的method,跟着书上写了一个拨打电话的示例。Intent的action采用ACTION_CALL, 同时Data采用自己的电话号码。
在XML中添加button,写好布局后,在MainActivity中添加具体函数
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void callmyself(View v){//添加button onclick响应函数
Intent it = new Intent();
it.setAction(Intent.ACTION_CALL);//ACTION_CALL实现拨号
it.setData(Uri.parse("tel:+86***********"));//实现具体拨什么号
startActivity(it);
}
书中也提示到要添加拨号权限。在AndroidManifest中添加权限
package="com.pa