Intent.migrateExtraStreamToClipData() on a null object reference

后端 未结 4 1764
小蘑菇
小蘑菇 2020-12-09 07:51

Started getting this error in the production version of my app.

java.lang.NullPointerException: Attempt to invoke virtual method \'boolean android.content.In         


        
相关标签:
4条回答
  • 2020-12-09 08:10

    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);
    }
    
    0 讨论(0)
  • 2020-12-09 08:11

    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.

    0 讨论(0)
  • 2020-12-09 08:13

    thats really works

    @Override
    public void startActivityForResult(Intent intent, int requestCode) {
        try {
            super.startActivityForResult(intent, requestCode);
        } catch (Exception ignored){}
    }
    
    0 讨论(0)
  • 2020-12-09 08:18

    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.

    0 讨论(0)
提交回复
热议问题