Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐞 FileUriExposedException when exporting a notepad via "SEND TO APPS" #992

Open
AltoRetrato opened this issue Jul 25, 2024 · 0 comments

Comments

@AltoRetrato
Copy link

Hi, Martin!

I can export a notepad via Notepad > Export Notepad as CSV and selecting SAVE TO DISK,
but I can't when I choose SEND TO APPS.

image

When I try SEND TO APPS it displays:

image

... and logs:
android.os.FileUriExposedException: file:///storage/emulated/0/output.csv exposed beyond app through ClipData.Item.getUri()

More logs:

07-25 19:04:46.734  9586  9586 I Aedict:Views: Export Anki CSV to: got 16 listeners; alwaysPick=true, forcing showing of the chooser dialog
07-25 19:04:46.741  9586  9586 E Aedict:Exporter2: Failed to send exported CSV via Intent
07-25 19:04:46.741  9586  9586 E Aedict:Exporter2: android.os.FileUriExposedException: file:///storage/emulated/0/output.csv exposed beyond app through ClipData.Item.getUri()
07-25 19:04:46.741  9586  9586 E Aedict:Exporter2:  at android.os.StrictMode.onFileUriExposed(StrictMode.java:1978)
07-25 19:04:46.741  9586  9586 E Aedict:Exporter2:  at android.net.Uri.checkFileUriExposed(Uri.java:2371)
07-25 19:04:46.741  9586  9586 E Aedict:Exporter2:  at android.content.ClipData.prepareToLeaveProcess(ClipData.java:966)
07-25 19:04:46.741  9586  9586 E Aedict:Exporter2:  at android.content.Intent.prepareToLeaveProcess(Intent.java:10902)
07-25 19:04:46.741  9586  9586 E Aedict:Exporter2:  at android.content.Intent.prepareToLeaveProcess(Intent.java:10908)
07-25 19:04:46.741  9586  9586 E Aedict:Exporter2:  at android.content.Intent.prepareToLeaveProcess(Intent.java:10887)
07-25 19:04:46.741  9586  9586 E Aedict:Exporter2:  at android.app.Instrumentation.execStartActivity(Instrumentation.java:1667)
07-25 19:04:46.741  9586  9586 E Aedict:Exporter2:  at android.app.Activity.startActivityForResult(Activity.java:4689)
07-25 19:04:46.741  9586  9586 E Aedict:Exporter2:  at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:728)
07-25 19:04:46.741  9586  9586 E Aedict:Exporter2:  at android.app.Activity.startActivityForResult(Activity.java:4647)
07-25 19:04:46.741  9586  9586 E Aedict:Exporter2:  at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:709)
07-25 19:04:46.741  9586  9586 E Aedict:Exporter2:  at android.app.Activity.startActivity(Activity.java:5008)
07-25 19:04:46.741  9586  9586 E Aedict:Exporter2:  at android.app.Activity.startActivity(Activity.java:4976)
07-25 19:04:46.741  9586  9586 E Aedict:Exporter2:  at sk.baka.aedict3.util.android.Views.sendTo(Views.java:84)
07-25 19:04:46.741  9586  9586 E Aedict:Exporter2:  at sk.baka.aedict3.util.export.Exporter2$ExportToCSVAsyncTask.sendAsIntent(Exporter2.java:560)
07-25 19:04:46.741  9586  9586 E Aedict:Exporter2:  at sk.baka.aedict3.util.export.Exporter2$ExportToCSVAsyncTask.onPostExecute(Exporter2.java:510)
07-25 19:04:46.741  9586  9586 E Aedict:Exporter2:  at sk.baka.aedict3.util.export.Exporter2$ExportToCSVAsyncTask.onPostExecute(Exporter2.java:406)
07-25 19:04:46.741  9586  9586 E Aedict:Exporter2:  at android.os.AsyncTask.finish(AsyncTask.java:695)
07-25 19:04:46.741  9586  9586 E Aedict:Exporter2:  at android.os.AsyncTask.access$600(AsyncTask.java:180)
07-25 19:04:46.741  9586  9586 E Aedict:Exporter2:  at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:712)
07-25 19:04:46.741  9586  9586 E Aedict:Exporter2:  at android.os.Handler.dispatchMessage(Handler.java:106)
07-25 19:04:46.741  9586  9586 E Aedict:Exporter2:  at android.os.Looper.loop(Looper.java:214)
07-25 19:04:46.741  9586  9586 E Aedict:Exporter2:  at android.app.ActivityThread.main(ActivityThread.java:7073)
07-25 19:04:46.741  9586  9586 E Aedict:Exporter2:  at java.lang.reflect.Method.invoke(Native Method)
07-25 19:04:46.741  9586  9586 E Aedict:Exporter2:  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
07-25 19:04:46.741  9586  9586 E Aedict:Exporter2:  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
07-25 19:04:46.742  5463  5529 D WindowManager: reportFocusChangedSerialized, focused=false, inTouchMode=true, win=Window{e67b05a u0 sk.baka.aedict3/sk.baka.aedict3.NotepadActivity EXITING}

Device: Samsung Note8, Android 9, One UI 1.0
Aedict 3.51.6

According to ChatGPT and Gemini:

Starting from Android 7.0 (API level 24), sharing file URIs across app boundaries using intents has been restricted to improve security. To resolve this issue, you should use a content:// URI instead of a file:// URI. You can achieve this by using a FileProvider.

If you need more information, please let me know.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant