1. Black Friday Sale - 50% off

    B4A Standard for $29 instead of $59!
    Buy Now
    Dismiss Notice

Android Tutorial Android Bluetooth / BluetoothAdmin Tutorial

Discussion in 'Tutorials & Examples' started by Erel, Feb 7, 2012.

Thread Status:
Not open for further replies.
  1. Scantech

    Scantech Well-Known Member Licensed User

    I will do some more investigating. I was in the apartment when I did a search. Not Sure how many other Bluetooth devices are around me. When Away from the apartments it is working properly.
     
    Last edited: Oct 21, 2015
  2. FrankBerra

    FrankBerra Active Member Licensed User

    DavideV likes this.
  3. techknight

    techknight Well-Known Member Licensed User

    Why they would put that in the locations permission is completely asinine, because this could lead into a false sense of "insecurity" when installing an app and someone actually looks at the permissions. "Why does it need to know my location?" phrase... GRRR google....

    Anyways... Can someone try on Android M if location is disabled, if BT discovery still works?
     
  4. FrankBerra

    FrankBerra Active Member Licensed User

    Yes it works
     
  5. DavideV

    DavideV Active Member Licensed User

    I agree with you about the permissions, too much for bluetooth discovery in my opinion.
    Could be for ibeacon?
    isn't it a sort of bluetooth localization?
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    DavideV likes this.
  7. DavideV

    DavideV Active Member Licensed User

  8. Gagandeep Singh

    Gagandeep Singh Member Licensed User

    Everytime i try to connect to any Bluetooth device i get this error,Please tell me where am i going wrong?

    Screenshot_2016-03-22-09-44-18.png
     
    Last edited: Mar 22, 2016
  9. Erel

    Erel Administrator Staff Member Licensed User

    You need to run this example on two Android devices.
     
  10. Mitesh_Shah

    Mitesh_Shah Member Licensed User

    HI CAN ANY ONE TRY IN NEW ANDROID OS 6.0 ?

    I AM TRY IT IN MY LENOVO K3 NOTE PHONE - ANDROID 6.0 IT'S NOT WORKING. GETTING ERROR DEVICE NOT FOUND

    BUT IT'S WORK IN KITKAT AND LOLLIPOP Version

    REGARD

    MITESH
     
  11. Erel

    Erel Administrator Staff Member Licensed User

    Please do not write ALL CAPS messages.

    Are you using B4A v5.80?
     
  12. Mitesh_Shah

    Mitesh_Shah Member Licensed User

    Hi Sir

    I am use B4A V3.0 now
     
  13. Erel

    Erel Administrator Staff Member Licensed User

    You need to add this permission with the manifest editor: android.permission.ACCESS_COARSE_LOCATION
     
  14. Mitesh_Shah

    Mitesh_Shah Member Licensed User

    Thank u sir

    Will try It
     
  15. Mitesh_Shah

    Mitesh_Shah Member Licensed User

    HI Erel

    I m add >>android.permission.ACCESS_COARSE_LOCATION to Region Module Attributes but, getting Compiling Error.

    Parsing code. Error
    Error parsing program.
    Error description: Attribute not supported: android
    Occurred on line: 10
    #Android:permission.ACCESS_COARSE_LOCATION
     
  16. Erel

    Erel Administrator Staff Member Licensed User

    You need to add it in the manifest editor: Project - Manifest Editor:
    Code:
    AddPermission(android.permission.ACCESS_COARSE_LOCATION)
     
  17. Mitesh_Shah

    Mitesh_Shah Member Licensed User

    Thnk's Sir

    Now It's Working
     
  18. red30

    red30 Active Member Licensed User

    I use your example. The data is transmitted. Not working reception ... What am I doing wrong?
    Code:
    #Region Module Attributes
        
    #FullScreen: False
        
    #IncludeTitle: True
    #End Region

    'Activity module
    Sub Process_Globals
        
    Dim AStream As AsyncStreams
        
    Dim bc As ByteConverter
    End Sub

    Sub Globals
        
    Dim readings As EditText
        
    Dim label1 As Label


    End Sub

    Sub Activity_Create(FirstTime As Boolean)
        
    Activity.LoadLayout("2")
        readings.Color = 
    Colors.black
        
    If AStream.IsInitialized = False Then
            
    'AStream.InitializePrefix(Main.serial1.InputStream, True, Main.serial1.OutputStream, "AStream")
            AStream.Initialize(Main.Serial1.InputStream, Main.Serial1.OutputStream, "AStreams")
        
    End If
    End Sub

    Sub AStreams_NewData (Buffer() As Byte)
        readings.Text=Buffer
        label1.Text=(
    "Data: " & bc.HexFromBytes(Buffer))
    End Sub

    Sub AStream_Error
        
    ToastMessageShow("Connection is broken."True)
    End Sub

    Sub AStream_Terminated
        AStream_Error
    End Sub

    Sub Activity_Resume
      
    End Sub

    Sub Activity_Pause (UserClosed As Boolean)
        
    If UserClosed Then
            AStream.Close
        
    End If
    End Sub

    Sub LightOn_Click
        AStream.Write(
    Array As Byte(0x00,0x05,0x3f))
    End Sub
     
  19. Erel

    Erel Administrator Staff Member Licensed User

    What is not working? NewData is not raised?
     
    red30 likes this.
  20. red30

    red30 Active Member Licensed User

    Yes! NewData is not raised...
     
Thread Status:
Not open for further replies.
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