Wednesday, May 2, 2012

Andriod Example - Bluetooth Show Paired Devices

Here is a very simple example that I thought might be helpful to someone. I have included the four files that have content that is key to setting up the application.

The program checks to see if the device has bluetooth. If the device does and it isn’t turned on the program will prompt the user to turn it one. Once bluetooth is running it lists the paired devices.

You should be able to create a new Android project in eclipse and then copy the code included below into the appropriate file.

As the SDK Emulator doesn’t emulate bluetooth this example will not run in the emulator.

This example is built upon the information in the Bluetooth Dev Guide on the Android Developers site and the Android-Java Bluetooth on Samsung Galaxy post on stackoverflow.com.

Below the code attachments you will find a screen capture of what it looks like running on my Acer A100.

If you have any suggestions or questions please post them as comments.

ShowPaired.java
goes in <ProjectRoot>\src\com\example\showpaired\

strings.xml
goes in <ProjectRoot>\res\values\

main.xml
goes in <ProjectRoot>\res\layout\

AndroidManifest.xml
goes in <ProjectRoot>

Screen Capture from Acer A100



Notes:

  1. The code highlighting is done using SyntaxHighlighter which is maintained by Alex Gorbatchev and can be found at http://alexgorbatchev.com/SyntaxHighlighter/.
  2. This example is built upon the work of others. I post it here not as an example of original work but rather as a complete working example for reference. If I didn't appropriately credit you for your work please let me know and I will add you.

4 comments:

Anonymous said...

Thanks, good example... :)

Unknown said...

Can you tell me how to send a file using bluetooth.

digitalhack said...

Aravinth,

This isn't something I have done and at the present time I am without a functioning Android device.

digitalhack

Unknown said...

can you send me that project? I couldn't work , i am new on Android.