AleBarreto / FirebaseAndroidChat

Chat with features : Login with Google | Send Photo Camera | Send Photo Gallery | Send Location
591 stars 241 forks source link

file:// scheme is now not allowed to be attached with Intent on targetSdkVersion 24 (Android Nougat) #18

Closed CRUSADER1912 closed 7 years ago

CRUSADER1912 commented 7 years ago

When you try to access capture photo from camera an exception is thrown on Android Nougat

Log traces of the exception:- FATAL EXCEPTION: main Process: alessandro.firebaseandroid, PID: 8232 android.os.FileUriExposedException: file:///storage/emulated/0/Pictures/2017-03-04_042338camera.jpg exposed beyond app through ClipData.Item.getUri() at android.os.StrictMode.onFileUriExposed(StrictMode.java:1813) at android.net.Uri.checkFileUriExposed(Uri.java:2360) at android.content.ClipData.prepareToLeaveProcess(ClipData.java:832) at android.content.Intent.prepareToLeaveProcess(Intent.java:8957) at android.content.Intent.prepareToLeaveProcess(Intent.java:8942) at android.app.Instrumentation.execStartActivity(Instrumentation.java:1583) at android.app.Activity.startActivityForResult(Activity.java:4228) at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:48) at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:75) at android.app.Activity.startActivityForResult(Activity.java:4187) at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:871) at alessandro.firebaseandroid.MainActivity.photoCameraIntent(MainActivity.java:288) at alessandro.firebaseandroid.MainActivity.onOptionsItemSelected(MainActivity.java:163) at android.app.Activity.onMenuItemSelected(Activity.java:3208) at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:421) at android.support.v7.app.AppCompatActivity.onMenuItemSelected(AppCompatActivity.java:188) at android.support.v7.view.WindowCallbackWrapper.onMenuItemSelected(WindowCallbackWrapper.java:103) at android.support.v7.app.AppCompatDelegateImplV7.onMenuItemSelected(AppCompatDelegateImplV7.java:663) at android.support.v7.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:810) at android.support.v7.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:152) at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:957) at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:947) at android.support.v7.view.menu.MenuPopup.onItemClick(MenuPopup.java:126) at android.widget.AdapterView.performItemClick(AdapterView.java:310) at android.widget.AbsListView.performItemClick(AbsListView.java:1155) at android.widget.AbsListView$PerformClick.run(AbsListView.java:3152) at android.widget.AbsListView$3.run(AbsListView.java:4067) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6123) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)

CRUSADER1912 commented 7 years ago

I did find a nice post which will help in tackling this issue

Post reference:- https://inthecheesefactory.com/blog/how-to-share-access-to-file-with-fileprovider-on-android-nougat/en

AleBarreto commented 7 years ago

Thank you, you can send a pull request ? @CRUSADER1912

CRUSADER1912 commented 7 years ago

Sure, will do