I have the next code :
public class AddPrinter extends ListActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
bluetoothAdapter.startDiscovery();
filter = new IntentFilter();
filter.addAction(BluetoothDevice.ACTION_FOUND);
filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_STARTED);
filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
registerReceiver(receiver, filter);
}
BroadcastReceiver receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
System.out.println(action);
if (BluetoothDevice.ACTION_FOUND.equals(action)) {
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
adapter.add(device);
}
else if (BluetoothAdapter.ACTION_DISCOVERY_STARTED.equals(intent.getAction())) {
System.out.println("STARTED");
}
else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(intent.getAction())) {
Utils.dialog.dismiss();
}
}
};
The problem i have is so weird, for some reason the ACTION_DISCOVERY_STARTED is never called, but all the other actions are fine, what am i missing? thank you for your time.
try this
put
bluetoothAdapter.startDiscovery();after registering recevier