ghmxr / apkextractor

an android application using to extract app packages installed on the device
GNU General Public License v3.0
147 stars 29 forks source link

android.os.FileUriExposedException error when increase target to 24+ eg( targetSdkVersion 29 ) #4

Closed ghanimkhan closed 4 years ago

ghmxr commented 4 years ago

After API 24, it is not supported to create sharing intents of "android.intent.action.SEND" or "android.intent.action.SEND_MULTIPLE" including uri created by "Uri.fromFile()" or the system will throw an exception. This APP's target api is 23 in order to share APK directly in path /data/app . If you want to set the target API to 24+, try to use the static method EnvironmentUtil.getUriForFileByFileProvider(context,file) to obtain an uri instance and send it into an sharing intent.

You may refer to the following code to make a change in ShareSelectionDialog.java:75 //uris.add(Uri.fromFile(fileItem.getFile())); uris.add(EnvironmentUtil.getUriForFileByFileProvider(getContext(),fileItem.getFile()));

ghanimkhan commented 4 years ago

I have fix the issue by creating a provider and personalized geturi ,if you want I can help you with that?

ghanimkhan commented 4 years ago

One quick tip the files which are receiving are getting saved in the package , why don't you create application, package and receive.?

ghmxr commented 4 years ago

I have fix the issue by creating a provider and personalized geturi ,if you want I can help you with that?

Thanks for your sharing. I have only pushed this app on github and an app store called coolapk(酷安), so it is no need for me to upgrade the target api right now. And it is more convenient to share apps in /data/app by Uri.fromFile() if the target api is 23 or lower.