HI all, I want to enable/disable bluetooth through the program..I has the following code.
But this sort of code is not working in SDK 1.5..How can i do the same in SDK 1.5.? | |||||||||
|
Android BluetoothAdapter docs say it has been available since API Level 5. API Level 5 is Android 2.0. You can try using a backport of the Bluetooth API (have not tried it personally): http://code.google.com/p/backport-android-bluetooth/ | ||||
this code worked for me.. | |||||||||||||
|
Here is a bit more robust way of doing this, also handling the return values of
And add the following permissions into your manifest file:
But remember these important points:
| |||||||||||||
|
The solution of prijin worked perfectly for me. It is just fair to mention that two additional permissions are needed:
When these are added, enabling and disabling works flawless with the default bluetooth adapter. | ||||
To Enable the Bluetooth you could use either of the following functions:
The second function is:
The difference is that the first function makes the app ask the user a permission to turn on the Bluetooth or to deny. The second function makes the app turn on the Bluetooth directly. To Disable the Bluetooth use the following function:
NOTE/ The first function needs only the following permission to be defined in the AndroidManifest.xml file:
While, the second and third functions need the following permissions: |
联系客服