Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8427673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:50:33+00:00 2026-06-10T04:50:33+00:00

Looking for some pointers to get me started. In my left hand I have

  • 0

Looking for some pointers to get me started.

In my left hand I have a SGS2 running ICS. I’ve got SL4A up and running and have installed Python 2.6.2

In my right hand I’ve got a generic chinese bluetooth RFID reader. It works, it reads tags (it has a display) and it’s paired with the phone.

I’d like them to play nicely – I want to script something that will keep watching the device and capture the codes as they are transmitted.

I’m no Python expert but I’ve been using it for some time now for building simple I/O jobs on web servers so I can just about find my way around.

Unusually though, I’m having real problems getting going with this – I can’t find any ‘getting started with Bluetooth and SL4A’ resources to get over that first step of establishing a persistent connection and monitoring output.

Any tips?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T04:50:34+00:00Added an answer on June 10, 2026 at 4:50 am

    it seems that what you need is the bluetooth facade. Here are some commands pertaining to bluetooth that might be helpful to you:

    bluetoothAccept
    bluetoothActiveConnections
    bluetoothConnect
    bluetoothDiscoveryCancel
    bluetoothDiscoveryStart
    bluetoothGetConnectedDeviceName
    bluetoothGetLocalAddress
    bluetoothGetLocalName
    bluetoothGetRemoteDeviceName
    bluetoothGetScanMode
    bluetoothIsDiscovering
    bluetoothMakeDiscoverable
    bluetoothRead
    bluetoothReadBinary
    bluetoothReadLine
    bluetoothReadReady
    bluetoothSetLocalName
    bluetoothStop
    bluetoothWrite
    bluetoothWriteBinary
    checkBluetoothState
    toggleBluetoothState
    

    To call any of these commands you would do something like

    import android
    droid = android.Android()
    #call your commands with droid.bluetoothcommand
    droid.bluetoothDiscoveryStart()
    #or
    droid.toggleBluetoothState(True)
    

    Here is an example of some bluetooth functions, it is included with SL4A, but I added the comments for clarity:

    import android #for bluetooth functions
    import time #for waiting
    
    #get everything setup
    droid = android.Android()
    
    #turn on bluetooth
    droid.toggleBluetoothState(True)
    
    #ask user
    droid.dialogCreateAlert('Be a server?')
    droid.dialogSetPositiveButtonText('Yes')
    droid.dialogSetNegativeButtonText('No')
    droid.dialogShow()
    
    #get user response to question
    result = droid.dialogGetResponse()
    
    #if the result is 'Yes' ('positive') then is_server is set to True
    is_server = result.result['which'] == 'positive'
    
    if is_server:
      #so if is_server is true make the device discoverable and accept the next connection
      droid.bluetoothMakeDiscoverable()
      droid.bluetoothAccept()
    else:
      #attempts to connect to a device over bluetooth, the logic being that if the phone
      #is not receiving a connection then the user is attempting to connect to something
      droid.bluetoothConnect()
    
    
    if is_server:
      result = droid.getInput('Chat', 'Enter a message').result #Gets a message to send 
      #via bluetooth
      if result is None:
        droid.exit() #exit if nothing is in the message
      droid.bluetoothWrite(result + '\n') #otherwise write the message
    
    while True: #receives a message
      message = droid.bluetoothReadLine().result
      droid.dialogCreateAlert('Chat Received', message)
      droid.dialogSetPositiveButtonText('Ok')
      droid.dialogShow()
      droid.dialogGetResponse()
      result = droid.getInput('Chat', 'Enter a message').result
      if result is None:
        break
      droid.bluetoothWrite(result + '\n')
    
    droid.exit()
    

    Finally, for a full list of bluetooth commands, check out http://code.google.com/p/android-scripting/wiki/ApiReference and scroll down to the bluetooth facade. Best of luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been looking around via Google for some pointers to get me going on
just looking for some advice, pointers, and suggestions for further reading. I have: 1
I'm looking for some pointers on implementing Custom Events in VB.NET (Visual Studio 2008,
Looking for some guidance on a WCF service I’m prototyping. I have a WCF
looking for some help with images referenced within the stylesheet. I have no problems
I have been looking all over google to find some answers to my questions
Just some days ago I started looking into a unit test framework called check,
I've never done OpenGL, but I'm looking for some pointers on this particular question
I'd like to get some pointers and /or sample code on how to use
I have created an array of pointers. I have used some of them as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.