I'm getting the error
IllegalArgumentException: Can only use lower 16 bits for requestCode
When I'm pressing Enable Google Play Services
in my app.
The code I have is
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;
}
Here's the StackTrace of the error
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)
How can I fix this error? Pressing the enable button works on Google Now, just not in the app I'm building.
My problem was
GooglePlayServicesUtil.getErrorDialog(resultCode, this, GooglePlayServicesUtil.GOOGLE_PLAY_SERVICES_VERSION_CODE)
Changing that line to
GooglePlayServicesUtil.getErrorDialog(resultCode, this, 9000)
made the button work correctly and open up the settings page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With