Intent.migrateExtraStreamToClipData() on a null object reference

后端 未结 4 1774
小蘑菇
小蘑菇 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);
    }
    

提交回复
热议问题