Android Question Intent to share/send a file via Bluetooth ?

Discussion in 'Android Questions' started by Devv, May 9, 2015.

  1. Devv

    Devv Active Member Licensed User

    Hi
    How could i make a share intent to share (send) a file via Bluetooth ?

    for example if i want to share the file /sdcard/1.apk how to do so with intent ?
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    You can use this code to share a file:
    Code:
    Sub SendFile(Dir As String, FileName As String)
       
    Dim In As Intent
       
    In.Initialize(In.ACTION_SEND,"file://" & File.Combine(Dir, FileName))
       
    In.SetType("*/*")
       
    StartActivity(In)
    End Sub
    The use will be able to choose Bluetooth from the list.
     
    luke2012 and Devv like this.
  3. chrjak

    chrjak Active Member Licensed User

    Hey,

    When I try this and i click on email the path it in the "To" line and nothing is in attachments.
    Dropbox and other apps are crashing as well. Do i have to set the file path into an extra? The code is the same as above....
    Please help me :)

    Regards

    Update: Filemanager manages to send the file. So the problem is not the file
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Where is the file located?
     
  5. Devv

    Devv Active Member Licensed User

    for me it is showing the send options but never send the file
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    Where is the file located?
     
  7. Devv

    Devv Active Member Licensed User

    Code:
    Dim In As Intent
               
    In.Initialize(In.ACTION_SEND,"file://" & File.Combine(File.DirRootExternal, "So Market/So-Market.apk"))
               
    In.SetType("application/vnd.android.package-archive")
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    What is the output of Log(File.Exists(File.DirRootExternal, "So Market/So-Market.apk")) ?
     
  9. Devv

    Devv Active Member Licensed User

    true
     
  10. Erel

    Erel Administrator Staff Member Licensed User

    Maybe the bluetooth app doesn't allow sending APKs. You can try it with a different file.
     
  11. Devv

    Devv Active Member Licensed User

    Code:
    Dim In As Intent
           
    In.Initialize(In.ACTION_SEND,"file://" & File.Combine(File.DirRootExternal, "test.txt"))
           
    In.SetType("*/*")
           
    StartActivity(In)
    even this is not working with me ...

    it is working for you ?
     
  12. Erel

    Erel Administrator Staff Member Licensed User

    Try to add this to the intent:
    Code:
    Dim u As Uri 'ContentResolver library
    u.Parse("file://" & File.Combine(File.DirRootExternal, "test.txt"))
    In.PutExtra("android.intent.extra.STREAM", u)
     
    luke2012 likes this.
  13. luke2012

    luke2012 Well-Known Member Licensed User

    The default Bluetooth directory in the target device is the same for All Android devices?
     
  14. Erel

    Erel Administrator Staff Member Licensed User

    Please start a new thread for this question.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice