android.permission.read_phone_state 不工作
android.permission.read_phone_state not working
我已经添加了访问 phone_state 的权限,但我仍然收到此异常“原因是:java.lang.SecurityException:需要 READ_PHONE_STATE:既不是用户 10052 也不是当前用户进程有 android.permission.READ_PHONE_STATE."
<?xml version="1.0" encoding="utf-8"?>
<manifestxmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.goh2.pronoornotepad" >
<uses-permission android:name="android.permission.read_phone_state" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<application
android:allowBackup="true"
android:icon="@drawable/pronoorpng"
android:label="@string/app_name"
android:theme="@android:style/Theme.Light" >
<activity
android:name=".Login"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
android:name=".MainScreen"
android:label="@string/title_activity_main_screen" >
</activity>
</application>
您必须以这种方式声明权限:
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
而不是那个
<uses-permission android:name="android.permission.read_phone_state" />
我已经添加了访问 phone_state 的权限,但我仍然收到此异常“原因是:java.lang.SecurityException:需要 READ_PHONE_STATE:既不是用户 10052 也不是当前用户进程有 android.permission.READ_PHONE_STATE."
<?xml version="1.0" encoding="utf-8"?>
<manifestxmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.goh2.pronoornotepad" >
<uses-permission android:name="android.permission.read_phone_state" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<application
android:allowBackup="true"
android:icon="@drawable/pronoorpng"
android:label="@string/app_name"
android:theme="@android:style/Theme.Light" >
<activity
android:name=".Login"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
android:name=".MainScreen"
android:label="@string/title_activity_main_screen" >
</activity>
</application>
您必须以这种方式声明权限:
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
而不是那个
<uses-permission android:name="android.permission.read_phone_state" />