Accessing the Local Bluetooth Device Adapter

Write App Reviews

Build your own Android App Dev Empire

Get Instant Access

The local Bluetooth device is controlled via the BluetoothAdapter class.

To access the default Bluetooth adapter on the host device call getDefaultAdapter, as shown in Listing 13-1. It is possible that some Android devices will feature multiple Bluetooth adapters, though it is currently only possible to access the default device.

LISTING 13-1: Accessing the default Bluetooth Adapter Available for downloadon BluetoothAdapter bluetooth = BluetoothAdapter.getDefaultAdapter();

To read any of the local Bluetooth Adapter properties, initiate discovery, or find bonded devices you will need to include the Bluetooth manifest permission. In order to modify any of the local device properties the bluetooth_admin uses-permission is also required.

<uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>

Was this article helpful?

0 0
Mobile Apps Made Easy

Mobile Apps Made Easy

Quick start guide to skyrocket your offline and online business success with mobile apps. If you know anything about mobile devices, you’ve probably heard that famous phrase coined by one of the mobile device’s most prolific creators proclaiming that there’s an app for pretty much everything.

Get My Free Training Guide

Post a comment