我收到了错误
IllegalArgumentException: Can only use lower 16 bits for requestCode
当我在我的应用中按Enable Google Play Services
时。
我的代码是
private boolean checkPlayServices() {
int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
Log.d("resultCode", String.valueOf(resultCode));
if (resultCode != ConnectionResult.SUCCESS) {
if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
GooglePlayServicesUtil.getErrorDialog(resultCode, this, GooglePlayServicesUtil.GOOGLE_PLAY_SERVICES_VERSION_CODE).show();
} else {
Log.i("FUApp", "This device is not supported.");
finish();
}
return false;
}
return true;
}
这是错误的StackTrace
01-29 14:15:30.714 10725-10725/com.example.fitnessunlimited.android E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.fitnessunlimited.android, PID: 10725
java.lang.IllegalArgumentException: Can only use lower 16 bits for requestCode
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:837)
at com.google.android.gms.internal.i.onClick(Unknown Source)
at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:166)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
如何修复此错误?按下启用按钮适用于Google即时,而不是在我正在构建的应用中。
答案 0 :(得分:4)
我的问题是
GooglePlayServicesUtil.getErrorDialog(resultCode, this, GooglePlayServicesUtil.GOOGLE_PLAY_SERVICES_VERSION_CODE)
将该行更改为
GooglePlayServicesUtil.getErrorDialog(resultCode, this, 9000)
使按钮正常工作并打开设置页面。