Android examples for android.bluetooth:Bluetooth
register Bluetooth Receiver
import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.content.BroadcastReceiver; import android.content.Context; import android.content.IntentFilter; public class Main{ public static String ACTION_PAIRING_REQUEST = "android.bluetooth.device.action.PAIRING_REQUEST"; static public void registerBluetoothReceiver(Context context, BroadcastReceiver receiver) { IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(BluetoothDevice.ACTION_FOUND); intentFilter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED); intentFilter.addAction(BluetoothAdapter.ACTION_DISCOVERY_STARTED); intentFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); intentFilter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED); intentFilter.addAction(ACTION_PAIRING_REQUEST); intentFilter/*from www . j ava2 s .co m*/ .addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED); context.registerReceiver(receiver, intentFilter); } }