Android 重复提醒需要权限的解决办法

来源:互联网 发布:nba07年总决赛数据 编辑:程序博客网 时间:2024/04/27 17:12

由于Android 6.0的新特性 许多敏感权限 需要在运行时申请    安卓6.0以下开发的代码一般都没加上权限检查


如打电话前之需要加上权限检查 然后申请权限 以后再使用这个功能的时候就不会弹出申请权限了



//intent启动拨打电话Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + "13226339705"));if (ActivityCompat.checkSelfPermission(this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {    ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.CALL_PHONE},111);    this.startActivity(intent);    return;}else {    this.startActivity(intent);}

PS 有许多手机厂商会把这个Android6.0的新特性屏蔽掉 这样运行时就不会申请权限。

0 0
原创粉丝点击