2

The bluetooth scan should stop as soon as it finds a device of choice, and then after stopping it should start again, when i do the following, i get error saying the app has stopped. i want to scan for 3 times, and store their radiuses.

private BluetoothAdapter mBtAdapter;
mBtAdapter.startDiscovery();

//this string stores the MAC Address of the required device
string name = "12:34:D3:s3:we";

private final BroadcastReceiver mReceiver = new BroadcastReceiver()
{
        @Override
        public void onReceive(Context context, Intent intent)
        {
            String action = intent.getAction();

            // When discovery finds a device
            if (BluetoothDevice.ACTION_FOUND.equals(action))
            {
                 if(device.getAddress.equals(name)){
                     mBtAdapter.cancelDiscovery();
                 }

            }

            else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action))
            {
                mBtAdapter.startDiscovery();

            }
        }
}
mjs
  • 2,837
  • 4
  • 28
  • 48
  • Did you Google? It's five years old, but this question seems very, very, very similar ... http://stackoverflow.com/questions/3285580/how-to-periodically-scan-for-bluetooth-devices-on-android – Mawg says reinstate Monica May 19 '15 at 10:00

0 Answers0