Android Question send a file to a specific BT device without pairing

JTmartins

Active Member
Licensed User
Longtime User
Hi everyone.

I know how to send a file via BT using intents, and I know how to send a file via serial connection.

What I have been strugling is a method of sending a file to a specific deviced (choosed inside the app), without the need for the other device (a phone or a PC) to be paired.

Using intents I always get the system app chooser, where you can select how to share (BT,email, SMS, etc). I do not want that. Using Serial would mean that the other phone would also need to be running a specific application and needed to be paired, as far as I can tell.

I want to discover all the BT devices available, user chooses the one it wants) and then the file is shared with that specific device (wich will obviously need to accept the file). All that done within my app, without using the system share chooser, and without the other part to need to run any specific app.

Any hints to help me on this ?

ManyThaks
J

***UPDATE ****

I managed to eliminate the need for the system app choser. Quite simple, actually. Just tested with :

B4X:
Sub SendFile(Dir As String, FileName As String)
   Dim u As Uri
   Dim Int As Intent
   Private a As String
   a=File.Combine(Dir, FileName)
   Log(a)
   u.Parse("file://" & a)
   Int.Initialize(In.ACTION_SEND,"")
   Int.SetComponent("com.android.bluetooth/.opp.BluetoothOppLauncherActivity")
   Int.PutExtra("android.intent.extra.STREAM",u)
   Int.SetType("*/*")
   StartActivity(Int)
End Sub
 
Last edited:
Top