This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Android and the fly likes Unable to obtain bluetooth adapter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "Unable to obtain bluetooth adapter" Watch "Unable to obtain bluetooth adapter" New topic
Author

Unable to obtain bluetooth adapter

Renjith Mohan
Ranch Hand

Joined: Nov 28, 2008
Posts: 65


Hi all,
I am writing a small bluetooth application to search for devices. However, the bluetooth adapter instance is always null. See the code below.



And the manifest file is


Message in the LogCat is null pointer exception at line 20 (refer BluetoothDemo.java)

What could be the reason?

Thanks in advance!

--Renjith
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5812
    
    7

Are you running this code on your phone or on the adapter? I don't think that the adapter has bluetooth.

Also, you code could use some rearranging - you check adapter for null twice while you you could check just once, and you should not use adapter (lines 20-22) unless it is non-null


JBoss In Action
Renjith Mohan
Ranch Hand

Joined: Nov 28, 2008
Posts: 65

I tried running it on an emulator as well on the phone. Every time I try on the phone, it ends up with the message

The application has stopped unexpectedly. Please try later.

Yeah, i wrote it twice. it was a typo...the actual source has only one check.
Renjith Mohan
Ranch Hand

Joined: Nov 28, 2008
Posts: 65


By the way, BluetoothAdapter class is used to check if bluetooth is supported in the device.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to obtain bluetooth adapter
 
Similar Threads
how to transfer images to ftp server in android
Can't make SocketServer in the emulator
How to pass POJOs / data / values between activities?
how to view a web camera via URL
My Custom Intents do not work