申请权限遇到的错误
java.lang.RuntimeException: Unable to resume activity {com.y.account.RegisterActivity}: java.lang.IllegalArgumentException: Can only use lower 8 bits for requestCode
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3103)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3134)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2481)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.IllegalArgumentException: Can only use lower 8 bits for requestCode
at android.support.v4.app.FragmentActivity.validateRequestPermissionsRequestCode(FragmentActivity.java:799)
at android.support.v4.app.ActivityCompatApi23.requestPermissions(ActivityCompat23.java:29)
at android.support.v4.app.ActivityCompat.requestPermissions(ActivityCompat.java:316)
at com..permission.PermissionsManagers._requestPermissions(PermissionsManagers.java:73)
at com..permission.PermissionsManagers.requestPermissions(PermissionsManagers.java:35)
at com.i.i.activity.account.RegisterActivity.onResume(RegisterActivity.java:576)
意思是requestcode不能大于2的8次方 即 0-255之间的值
将
public static final int REQUEST_CODE_ALL = 1000; public static final int REQUEST_CODE_CAMERA = 1001; public static final int REQUEST_CODE_READ_PHONE_STATE = 1002; public static final int REQUEST_CODE_WRITE_EXTERNAL_STORAGE = 1003; public static final int REQUEST_CODE_ACCESS_FINE_LOCATION = 1004; public static final int REQUEST_CODE_READ_CONTACTS = 1005; public static final int REQUEST_CODE_RECORD_AUDIO = 1006; public static final int REQUEST_CODE_RECEIVE_SMS = 1007;
修改为即可
public static final int REQUEST_CODE_ALL = 8; public static final int REQUEST_CODE_CAMERA = 16; public static final int REQUEST_CODE_READ_PHONE_STATE = 24; public static final int REQUEST_CODE_WRITE_EXTERNAL_STORAGE = 32; public static final int REQUEST_CODE_ACCESS_FINE_LOCATION = 40; public static final int REQUEST_CODE_READ_CONTACTS = 48; public static final int REQUEST_CODE_RECORD_AUDIO = 56; public static final int REQUEST_CODE_RECEIVE_SMS = 64;