请求READ_CONTACTS权限Android M时出错

时间:2016-05-12 11:46:06

标签: android android-6.0-marshmallow

我正在尝试获取READ_CONTACTS权限Android M并致电:

ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_CONTACTS}, 1);

应用程序崩溃并出现以下异常:

05-12 17:08:24.578: E/AndroidRuntime(2846): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.packageinstaller/com.android.packageinstaller.permission.ui.GrantPermissionsActivity}: java.lang.NullPointerException: Attempt to get length of null array
05-12 17:08:24.578: E/AndroidRuntime(2846):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
05-12 17:08:24.578: E/AndroidRuntime(2846):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
05-12 17:08:24.578: E/AndroidRuntime(2846):     at android.app.ActivityThread.-wrap11(ActivityThread.java)
05-12 17:08:24.578: E/AndroidRuntime(2846):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
05-12 17:08:24.578: E/AndroidRuntime(2846):     at android.os.Handler.dispatchMessage(Handler.java:102)
05-12 17:08:24.578: E/AndroidRuntime(2846):     at android.os.Looper.loop(Looper.java:148)
05-12 17:08:24.578: E/AndroidRuntime(2846):     at android.app.ActivityThread.main(ActivityThread.java:5417)
05-12 17:08:24.578: E/AndroidRuntime(2846):     at java.lang.reflect.Method.invoke(Native Method)
05-12 17:08:24.578: E/AndroidRuntime(2846):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
05-12 17:08:24.578: E/AndroidRuntime(2846):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
05-12 17:08:24.578: E/AndroidRuntime(2846): Caused by: java.lang.NullPointerException: Attempt to get length of null array
05-12 17:08:24.578: E/AndroidRuntime(2846):     at com.android.packageinstaller.permission.ui.GrantPermissionsActivity.computePermissionGrantState(GrantPermissionsActivity.java:293)
05-12 17:08:24.578: E/AndroidRuntime(2846):     at com.android.packageinstaller.permission.ui.GrantPermissionsActivity.updateDefaultResults(GrantPermissionsActivity.java:343)
05-12 17:08:24.578: E/AndroidRuntime(2846):     at com.android.packageinstaller.permission.ui.GrantPermissionsActivity.onCreate(GrantPermissionsActivity.java:100)
05-12 17:08:24.578: E/AndroidRuntime(2846):     at android.app.Activity.performCreate(Activity.java:6251)
05-12 17:08:24.578: E/AndroidRuntime(2846):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
05-12 17:08:24.578: E/AndroidRuntime(2846):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)

我还在清单文件中指定了<uses-permission android:name="android.permission.READ_CONTACTS" />

0 个答案:

没有答案