当Androidstudio添加权限后仍然报错
1.AndroidMainfest.xml文件里添加一行代码
<uses-permission android:name="android.permission.CALL_PHONE"/>
//android.permission.CALL_PHONE为权限的名字
具体如下:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.fifth">
<uses-permission android:name="android.permission.CALL_PHONE"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Fifth">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
2.在MainActivity.java代码中添加权限请求
ActivityCompat.requestPermissions(MainActivity.this,
new String[]{Manifest.permission.CALL_PHONE},1);
在需要什么权限,更改Manifest.permission.CALL_PHONE就行