It may not work because EXTRA_RSSI value is a short type instead of
int. This works great for me:

short rssi = intent.getShortExtra(BluetoothDevice.EXTRA_RSSI,
Short.MIN_VALUE);

Take into consideration that rssi values are usually negative (it
could be dBm but I am not sure).


On 28 ene, 20:47, Chris <[email protected]> wrote:
> I'm trying to determine location via bluetooth beacons and while I can
> discover and find all of the devices around me, when I try to grab the
> EXTRA_RSSI that's supposed to come through it doesn't work.  Here's
> the code I'm using and I get a 0 every time.
>
> private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
>         @Override
>         public void onReceive(Context context, Intent intent) {
>                 Toast.makeText(ScannerActivity.this, "In BroadcastReceiver", 
> 3);
>             String action = intent.getAction();
>             // When discovery finds a device
>             if (BluetoothDevice.ACTION_FOUND.equals(action)) {
>                 // Get the BluetoothDevice object from the Intent
>                 BluetoothDevice device = intent.getParcelableExtra
> (BluetoothDevice.EXTRA_DEVICE);
>                 int rssi = intent.getIntExtra
> (BluetoothDevice.EXTRA_RSSI, 0);
>
>                 // Add the name and address to an array adapter to
> show in a ListView
>                 if (device.getBondState() !=
> BluetoothDevice.BOND_BONDED) {
>                     //do something
>                 }
>             }
>        }
>
> }

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to