我之前在以下链接中发布了一个问题:
然后我编写开发人员文档中提到的以下代码
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION)
== PackageManager.PERMISSION_GRANTED) {
if (!ActivityCompat.shouldShowRequestPermissionRationale(this,
Manifest.permission.ACCESS_FINE_LOCATION)) {
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
MAP_PERMISSION_REQUEST_CODE);
}
}
和
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
switch (requestCode) {
case MAP_PERMISSION_REQUEST_CODE: {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
initalizeMap();
} else {
DialogUtils.showDialogMessage(this, getString(R.string.error), getString(R.string.error_location_permission_not_granted), getString(R.string.ok), null);
}
return;
}
}
}
现在当我运行代码时,我遇到了以下崩溃
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.forsale.forsale/com.forsale.forsale.view.ItemDetailsActivity2}: java.lang.IllegalArgumentException: Can only use lower 8 bits for requestCode
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3253)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)
at android.app.ActivityThread.access$1100(ActivityThread.java:221)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7225)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
任何人都可以帮忙吗?