Android Question [SOLVED] Send file to PC via BLUETOOTH

rosippc64a

Active Member
Licensed User
Longtime User
Hi All,
I would like to send a csv file to PC via bluetooth.
I use fileprovider, and this code:
B4X:
        Dim txw As TextWriter
        'txw.Initialize2(File.OpenOutput(Starter.Provider.SharedFolder, csvnev,False),"Windows-1250")
        txw.Initialize2(File.OpenOutput(Starter.Provider.SharedFolder, csvnev,False),"utf8")
        txw.Write(sb.ToString)
        txw.Close
        Dim phone As Phone
        Dim in As Intent
        If phone.SdkVersion >= 24 Then
            in.Initialize(in.ACTION_SEND, "")
            in.SetType("text/plain") 
            in.PutExtra("android.intent.extra.STREAM", Starter.Provider.GetFileUri(File.Combine(Starter.Provider.SharedFolder,csvnev)))
            in.Flags = 1 'FLAG_GRANT_READ_URI_PERMISSION
        Else
            in.Initialize(in.ACTION_SEND, "file://" & File.Combine(Starter.Provider.SharedFolder, csvnev))
            in.SetType("text/plain")
        End If
        StartActivity(in)
The android device (android 7.0) is paired to the PC (win10). I started the file receive on the PC.
When my intent runs, I can select the PC, and the sending starts, but ends with error (after some minute): "file not sent" and on the PC there is no clue receiving any file.
What wrong I do?
 

rosippc64a

Active Member
Licensed User
Longtime User
ok, now works. I have to put this into manifest:
B4X:
CreateResource(xml, provider_paths,
   <external-files-path name="name" path="shared" />
)
I missed that, because there was another similar line ( I didn't checked what is the difference between root-path and external-files-path...):
B4X:
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,
<root-path name="root" path="." />
)
 
Upvote 0
Top