coomar2841 / image-chooser-library

An Easy Image/Video Chooser Library for your Android Apps
646 stars 191 forks source link

android.os.FileUriExposedException: file:///storage/emulated/0 exposed beyond app through ClipData.Item.getUri() in android 7 #204

Closed kikani89 closed 7 years ago

kikani89 commented 7 years ago

vq3.glassframe.quickcode.com.glassframe W/System.err: android.os.FileUriExposedException: file:///storage/emulated/0/bichooser/1491833482318.jpg exposed beyond app through ClipData.Item.getUri() vq3.glassframe.quickcode.com.glassframe W/System.err: at android.os.StrictMode.onFileUriExposed(StrictMode.java:1799) vq3.glassframe.quickcode.com.glassframe W/System.err: at android.net.Uri.checkFileUriExposed(Uri.java:2346) vq3.glassframe.quickcode.com.glassframe W/System.err: at android.content.ClipData.prepareToLeaveProcess(ClipData.java:845) vq3.glassframe.quickcode.com.glassframe W/System.err: at android.content.Intent.prepareToLeaveProcess(Intent.java:8941) vq3.glassframe.quickcode.com.glassframe W/System.err: at android.content.Intent.prepareToLeaveProcess(Intent.java:8926) vq3.glassframe.quickcode.com.glassframe W/System.err: at android.app.Instrumentation.execStartActivity(Instrumentation.java:1517) vq3.glassframe.quickcode.com.glassframe W/System.err: at android.app.Activity.startActivityForResult(Activity.java:4225) vq3.glassframe.quickcode.com.glassframe W/System.err: at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:50) vq3.glassframe.quickcode.com.glassframe W/System.err: at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:79) vq3.glassframe.quickcode.com.glassframe W/System.err: at android.support.v4.app.ActivityCompatJB.startActivityForResult(ActivityCompatJB.java:30) vq3.glassframe.quickcode.com.glassframe W/System.err: at android.support.v4.app.ActivityCompat.startActivityForResult(ActivityCompat.java:146) vq3.glassframe.quickcode.com.glassframe W/System.err: at android.support.v4.app.FragmentActivity.startActivityFromFragment(FragmentActivity.java:937) vq3.glassframe.quickcode.com.glassframe W/System.err: at android.support.v4.app.FragmentActivity$HostCallbacks.onStartActivityFromFragment(FragmentActivity.java:1047) vq3.glassframe.quickcode.com.glassframe W/System.err: at android.support.v4.app.Fragment.startActivityForResult(Fragment.java:959) vq3.glassframe.quickcode.com.glassframe W/System.err: at android.support.v4.app.Fragment.startActivityForResult(Fragment.java:948) vq3.glassframe.quickcode.com.glassframe W/System.err: at com.kbeanie.imagechooser.api.BChooser.startActivity(BChooser.java:159) vq3.glassframe.quickcode.com.glassframe W/System.err: at com.kbeanie.imagechooser.api.ImageChooserManager.takePicture(ImageChooserManager.java:251) vq3.glassframe.quickcode.com.glassframe W/System.err: at com.kbeanie.imagechooser.api.ImageChooserManager.choose(ImageChooserManager.java:217) vq3.glassframe.quickcode.com.glassframe W/System.err: at vq3.glassframe.quickcode.com.glassframe.StartFragment.takePicture(StartFragment.java:108) vq3.glassframe.quickcode.com.glassframe W/System.err: at vq3.glassframe.quickcode.com.glassframe.StartFragment.access$100(StartFragment.java:40) vq3.glassframe.quickcode.com.glassframe W/System.err: at vq3.glassframe.quickcode.com.glassframe.StartFragment$1.onNavigationItemSelected(StartFragment.java:68) vq3.glassframe.quickcode.com.glassframe W/System.err: at android.support.design.widget.BottomNavigationView$1.onMenuItemSelected(BottomNavigationView.java:184) vq3.glassframe.quickcode.com.glassframe W/System.err: at android.support.v7.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:822) vq3.glassframe.quickcode.com.glassframe W/System.err: at android.support.v7.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:156) vq3.glassframe.quickcode.com.glassframe W/System.err: at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:969) vq3.glassframe.quickcode.com.glassframe W/System.err: at android.support.design.internal.BottomNavigationMenuView$1.onClick(BottomNavigationMenuView.java:90) vq3.glassframe.quickcode.com.glassframe W/System.err: at android.view.View.performClick(View.java:5637) vq3.glassframe.quickcode.com.glassframe W/System.err: at android.view.View$PerformClick.run(View.java:22429) vq3.glassframe.quickcode.com.glassframe W/System.err: at android.os.Handler.handleCallback(Handler.java:751) vq3.glassframe.quickcode.com.glassframe W/System.err: at android.os.Handler.dispatchMessage(Handler.java:95) vq3.glassframe.quickcode.com.glassframe W/System.err: at android.os.Looper.loop(Looper.java:154) vq3.glassframe.quickcode.com.glassframe W/System.err: at android.app.ActivityThread.main(ActivityThread.java:6119) vq3.glassframe.quickcode.com.glassframe W/System.err: at java.lang.reflect.Method.invoke(Native Method) vq3.glassframe.quickcode.com.glassframe W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) vq3.glassframe.quickcode.com.glassframe W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

kikani89 commented 7 years ago

solved check out this. kikani89 / image-chooser-library

tvats1988 commented 7 years ago

Just paste the below code in activity onCreate()

StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder(); StrictMode.setVmPolicy(builder.build());

It will ignore URI exposure

ajitdubey-mob-ibtech commented 7 years ago

@tvats1988 i think it is workaround not a good solutions. is it?

hnliufuqiang commented 7 years ago

StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder(); StrictMode.setVmPolicy(builder.build());这个为什么要用这个