Android Question VideoRecordApp: crash with FileUriExposedException

Eldad Onojetah

Member
Licensed User
Hi,

I am using VideoRecordApp to record a video and it crashes on Android > 7 (> api 24)

Code I am using:
B4X:
'Provider is a Fileprovider that has been configured
'Also my manifest has FileProvider snippet correctly
videoRecorder.Record2(Starter.Provider.SharedFolder, SendReport.EvidenceFilename, 15)

Error:
B4X:
** Activity (sendreportactivity) Resume **
Error occurred on line: 298 (SendReportActivity)
android.os.FileUriExposedException: file:///storage/emulated/0/Android/data/com.ohiritech.app/files/Evidence 1.mp4 exposed beyond app through ClipData.Item.getUri()
    at android.os.StrictMode.onFileUriExposed(StrictMode.java:1799)
    at android.net.Uri.checkFileUriExposed(Uri.java:2346)
    at android.content.ClipData.prepareToLeaveProcess(ClipData.java:832)
    at android.content.Intent.prepareToLeaveProcess(Intent.java:8909)
    at android.content.Intent.prepareToLeaveProcess(Intent.java:8894)
    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1517)
    at android.app.Activity.startActivityForResult(Activity.java:4224)
    at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:767)
    at android.app.Activity.startActivityForResult(Activity.java:4183)
    at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:754)
    at anywheresoftware.b4a.BA.startActivityForResult(BA.java:542)
    at anywheresoftware.b4a.audio.AudioRecordApp$VideoRecordApp.Record2(AudioRecordApp.java:263)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:777)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:354)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA$2.run(BA.java:370)
    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:6077)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

What's the solution? I also use AudioRecordApp and it works well.

Kind regards.
 

DonManfred

Expert
Licensed User
Upvote 0

Eldad Onojetah

Member
Licensed User
@DonManfred sorry, am at a loss here. At what point do I copy the file AND create a fileprovider uri?

1. The app crashes on this line
B4X:
videoRecorder.Record2(Starter.Provider.SharedFolder, SendReport.EvidenceFilename, 15)
] and I have no access to the video file it has created.
2. I have successfully used the Fileprovider uri to share a file which works
3. I also use
B4X:
AudioRecorderApp
and this works well.

Can you give me a pointer on what to do?
 
Upvote 0

Eldad Onojetah

Member
Licensed User
Firebase crash report
B4X:
android.os.StrictMode.onFileUriExposed (StrictMode.java:1814)
android.net.Uri.checkFileUriExposed (Uri.java:2346)
android.content.ClipData.prepareToLeaveProcess (ClipData.java:832)
android.content.Intent.prepareToLeaveProcess (Intent.java:8927)
android.content.Intent.prepareToLeaveProcess (Intent.java:8912)
android.app.Instrumentation.execStartActivity (Instrumentation.java:1517)
android.app.Activity.startActivityForResult (Activity.java:4289)
android.support.v4.app.FragmentActivity.startActivityForResult (FragmentActivity.java:767)
android.app.Activity.startActivityForResult (Activity.java:4248)
android.support.v4.app.FragmentActivity.startActivityForResult (FragmentActivity.java:754)
'''this line is highlighted in bold as where the cause of error is
anywheresoftware.b4a.BA.startActivityForResult (BA.java:542)

anywheresoftware.b4a.audio.AudioRecordApp$VideoRecordApp.Record2 (AudioRecordApp.java:263)
anywheresoftware.b4a.audio.AudioRecordApp$VideoRecordApp.Record (AudioRecordApp.java:204)
com.ohiritech.police.reporter.sendreportactivity._dmpattach_onclicked (sendreportactivity.java:868)
java.lang.reflect.Method.invoke (Method.java)
anywheresoftware.b4a.BA.raiseEvent2 (BA.java:196)
 
Upvote 0
Top