Android Question With B4X, how can you download or read files received by WhatsApp?

Omar Moreno

Member
Licensed User
Longtime User
Hello everyone.

The lista.txt (text/plain) file has been sent to another device via WhatsApp with this code:
B4X, Manifest Editor:
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" />
)

B4X, Send File:
Sub shareFile(filetxt As String)
    'File previously written to Provider.SharedFolder
    Dim in As Intent
    ' Inicializar
    in.Initialize(in.ACTION_SEND, "")
    Provider.SetFileUriAsIntentData(in, filetxt)
    in.SetComponent("android/com.android.internal.app.ResolverActivity")
    'in.SetType("application/pdf")
    in.SetType("text/plain")
    in.PutExtra("android.intent.extra.STREAM", Provider.GetFileUri(filetxt))
    in.SetPackage("com.whatsapp")
    StartActivity(in)
End Sub

1693851873939.png


The files arrive on cell phones, but through B4X code how can I get the data contained in the file to process it?

Thank you for your possible answers.
 
Top