Android Question MobileVision lib sdk 29

SMOOTSARA

Active Member
Licensed User
Hello friends
I use the following library

@DonManfred


This example works well because it has sdk 19

But when we change the sdk to 29, it gives the following error.


B4X:
*** Service (starter) Create ***
Using FileProvider? true
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Using FileProvider? true
** Activity (main) Resume **
Start Recognize... Recognizer ready = true
main_btntxtrecognizer_click (java line: 412)
android.os.FileUriExposedException: file:///storage/emulated/0/picture.jpg exposed beyond app through ClipData.Item.getUri()
    at android.os.StrictMode.onFileUriExposed(StrictMode.java:1796)
    at android.net.Uri.checkFileUriExposed(Uri.java:2346)
    at android.content.ClipData.prepareToLeaveProcess(ClipData.java:845)
    at android.content.Intent.prepareToLeaveProcess(Intent.java:8944)
    at android.content.Intent.prepareToLeaveProcess(Intent.java:8929)
    at android.app.Instrumentation.execStartActivity(Instrumentation.java:2213)
    at android.app.Activity.startActivityForResult(Activity.java:4286)
    at android.app.Activity.startActivityForResult(Activity.java:4244)
    at anywheresoftware.b4a.BA.startActivityForResult(BA.java:559)
    at de.donmanfred.TextRecognizerwrapper.takePicture(TextRecognizerwrapper.java:210)
    at b4a.example.main._btntxtrecognizer_click(main.java:412)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:197)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
    at android.view.View.performClick(View.java:5794)
    at android.view.View$PerformClick.run(View.java:22729)
    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:6138)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:893)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:783)


Now according to this guide

I got help from this link and installed this module


But still the problem is not solved.

main
B4X:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals


End Sub

Sub Globals

    Dim txtrecognizer As TextRecognizer
    Dim barcode As BarcodeDetector
    Dim face As FaceDetector
    Private lblResult As Label
    Private btntxtrecognizer As Button
    Private btnfacedetect As Button
    Private btnScanBarcode As Button
    Public Provider As FileProvider
    
End Sub

Sub Activity_Create(FirstTime As Boolean)
    
    Provider.Initialize
    Activity.LoadLayout("Layout1")
    txtrecognizer.Initialize("TxtRecognizer")
    barcode.Initialize("Barcode")
    face.Initialize("Face")
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub lblResult_Click
    
End Sub

Sub btntxtrecognizer_Click
    Log("Start Recognize... Recognizer ready = "&txtrecognizer.isOperational)
    If txtrecognizer.isOperational Then
        txtrecognizer.takePicture
    End If
End Sub

Sub TxtRecognizer_onOCRScanResult(success As Boolean, result As String)
    Log($"TxtRecognizer_onScanResults(${success},${result})"$)
End Sub
Sub Face_onFaceDetectResult(success As Boolean, result As String)
    Log($"Face_onFaceDetectResult(${success},${result})"$)
End Sub
Sub Barcode_onBarcodeResult(success As Boolean, info As String, result As List)
    Log($"Barcode_onBarcodeResult(${success}, ${info}, ${result})"$)
End Sub
Sub btnfacedetect_Click
    If face.isOperational Then
        face.takePicture
    End If       
End Sub

Sub btnScanBarcode_Click
    If barcode.isOperational Then
        barcode.takePicture
    End If
End Sub

manifest


B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="29"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.



AddManifestText(<uses-permission
   android:name="android.permission.WRITE_EXTERNAL_STORAGE"
   android:maxSdkVersion="18" />
)

AddApplicationText(
  <provider
  android:name="android.support.v4.content.FileProvider"
  android:authorities="$PACKAGE$.provider"
  android:exported="false"
  android:grantUriPermissions="true">
  <meta-data
  android:name="android.support.FILE_PROVIDER_PATHS"
  android:resource="@xml/provider_paths"/>
  </provider>
)
CreateResource(xml, provider_paths,
   <files-path name="name" path="shared" />
)
 
Top