java.lang.NullPointerException:uriString [share image]

时间:2017-10-18 20:24:04

标签: android share android-glide

我正在尝试向我的应用添加共享功能我尝试了这个代码,它在Android 5.0和Android 7.0上工作正常但是当我在Android 6.0.1上运行我的应用时出现此错误

  

流程:maa.myapp,PID:20195                                                                            java.lang.NullPointerException:uriString                                                                                在android.net.Uri $ StringUri。(Uri.java:476)                                                                                在android.net.Uri $ StringUri。(Uri.java:466)                                                                                在android.net.Uri.parse(Uri.java:438)                                                                                at maa.myapp.full $ 2 $ 2.onResourceReady(full.java:122)                                                                                在maa.myapp.full $ 2 $ 2.onResourceReady(full.java:118)

这是我的代码:

Glide.with(getApplicationContext())
                    .load(url)
                    .asBitmap()
                    .diskCacheStrategy(DiskCacheStrategy.ALL)
                    .into(new SimpleTarget<Bitmap>() {
                        @Override
                        public void onResourceReady(Bitmap resource, GlideAnimation<?super Bitmap> glideAnimation) {
                            String bitmapPath = MediaStore.Images.Media.insertImage(getContentResolver(), resource,"title", null);
                            Uri bitmapUri = Uri.parse(bitmapPath);
                            Intent intent = new Intent(Intent.ACTION_SEND);
                            intent.setType("image/png");
                            intent.putExtra(Intent.EXTRA_STREAM, bitmapUri);
                            startActivity(Intent.createChooser(intent, "Share"));
                            lt.success();
                        }
                    });

0 个答案:

没有答案