So I have 2 apps set up. One sending files and the other receiving the files. The app sending the files is written in Java, while the receiving end is written in B4a.
When trying to retrieving the file from the results I get a SecurityException.
Ive been stuck on this the past few days a bit of help would be appreciated.
The full Exception message:
The sending part of the first app is as follows:
While the receiving end written in B4a is as follows with comments noting what those values turn out to when debugging:
When trying to retrieving the file from the results I get a SecurityException.
Ive been stuck on this the past few days a bit of help would be appreciated.
The full Exception message:
Exception:
Error occurred on line: 121 (DocScanUtils)
java.lang.SecurityException: Permission Denial: opening provider androidx.core.content.FileProvider from ProcessRecord{f732a21 8153:com.eureka.dispatchit/u0a155} (pid=8153, uid=10155) that is not exported from UID 10159
at android.os.Parcel.createExceptionOrNull(Parcel.java:2373)
at android.os.Parcel.createException(Parcel.java:2357)
at android.os.Parcel.readException(Parcel.java:2340)
at android.os.Parcel.readException(Parcel.java:2282)
at android.app.IActivityManager$Stub$Proxy.getContentProvider(IActivityManager.java:5702)
at android.app.ActivityThread.acquireProvider(ActivityThread.java:6813)
at android.app.ContextImpl$ApplicationContentResolver.acquireUnstableProvider(ContextImpl.java:2935)
at android.content.ContentResolver.acquireUnstableProvider(ContentResolver.java:2481)
at android.content.ContentResolver.query(ContentResolver.java:1167)
at android.content.ContentResolver.query(ContentResolver.java:1115)
at android.content.ContentResolver.query(ContentResolver.java:1071)
at anywheresoftware.b4a.objects.ContentResolverWrapper.Query(ContentResolverWrapper.java:49)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
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.raiseEvent(BA.java:193)
at anywheresoftware.b4j.object.JavaObject$1.invoke(JavaObject.java:238)
at java.lang.reflect.Proxy.invoke(Proxy.java:1006)
at $Proxy1.ResultArrived(Unknown Source)
at anywheresoftware.b4a.BA$4.run(BA.java:585)
at anywheresoftware.b4a.BA.setActivityPaused(BA.java:459)
at com.eureka.dispatchit.home$ResumeMessage.run(home.java:313)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
The sending part of the first app is as follows:
Sending code:
//Create response intent.
Intent outIntent = new Intent(ACTION_RETURN_DOCUMENT);
File pdfFile = scanResult.pdfFile;
//Build the response with the Uri for the pdf file created.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N){
String authority = BuildConfig.APPLICATION_ID + ".fileprovider";
if (pdfFile != null) {
Uri finalPDF = FileProvider.getUriForFile(this.context, authority, pdfFile);
outIntent.putExtra(EXTRA_PDF_FILE_STREAM, finalPDF);
}
} else {
if (pdfFile != null) {
outIntent.putExtra(EXTRA_PDF_FILE_STREAM,Uri.fromFile(pdfFile));
}
}
outIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
outIntent.setFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
setResult(Activity.RESULT_OK,resultIntent);
finish();
While the receiving end written in B4a is as follows with comments noting what those values turn out to when debugging:
Recieving Code:
Private Sub ion_Event (MethodName As String, Args() As Object) As Object
Dim resultCode As Int = Args(0)
Dim intent As Intent = Args(1)
Log(intent) ''(Intent) Intent { act=com.eureka.documentscanner.RETURN_DOCUMENT flg=0x1 (has extras) }
Try
If intent.HasExtra(EXTRA_PDF_FILE_STREAM) Then
Dim pdfUri As String = UriUtils.getParcableExtra(intent,EXTRA_PDF_FILE_STREAM)
Log(pdfUri) ''uri: "content://com.eureka.documentscanner.fileprovider/files/8591356a-df5d-4204-ab68-55defaaca1b4.pdf"
Dim u As Uri
u.Parse(pdfUri)
Log(u)
Dim cr As ContentResolver : cr.Initialize("cr")
Dim cur As Cursor = cr.Query(u,Null,"",Null,"") ''CODE BREAKS HERE
Log(cur)
End If
Catch
Log(LastException)
End Try
Return Null
End Sub