Started getting this error in the production version of my app.
java.lang.NullPointerException: Attempt to invoke virtual method \'boolean android.content.In
Seems like the error occurs on devices where Google Play Services are not installed, passed intent will then be null.
You can make sure intent passed is not null by overriding startActivityForResult method in your Activity.
@Override
public void startActivityForResult(Intent intent, int requestCode) {
if (intent == null) {
intent = new Intent();
}
super.startActivityForResult(intent, requestCode);
}
This question is a bit old, but I just wanted to share an update on it. According to this Github issue on the GCM project the issue should be solved in Google Play Services version 9.4.0
. The accepted answer should work as well (as an intermediate patch), but if you update your Google Play Services library this issue should be solved.
thats really works
@Override
public void startActivityForResult(Intent intent, int requestCode) {
try {
super.startActivityForResult(intent, requestCode);
} catch (Exception ignored){}
}
Most probably it's the same problem as in getLaunchIntentForPackage is null for some apps. Not really a duplicate (since OP couldn't trace the offending line, which is known in linked question), but if someone faces this problem, linked question's solution might help.