Get bluetooth signal strength
To get the signal you can check Bluetooth RSSI, you can read RSSI for connected devices, or perform a Bluetooth discovery to check the RSSI for any nearby devices.
Basically a Bluetooth discovery is a broadcast to all stations within range to respond back. As each devices responds back, Android fires off an ACTION_FOUND intent. Within this intent you can getExtra EXTRA_RSSI to obtain the RSSI.
Note that not all bluetooth hardware supports RSSI.
Also Related: Android IRC Office Hours Question About Android Bluetooth RSSI
here is a Bluetooth Classic broadcast receiver example
private final BroadcastReceiver receiver = new BroadcastReceiver(){
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if(BluetoothDevice.ACTION_FOUND.equals(action)) {
short rssi = intent.getShortExtra(BluetoothDevice.EXTRA_RSSI,Short.MIN_VALUE);
Toast.makeText(getApplicationContext()," RSSI: " + rssi + "dBm", Toast.LENGTH_SHORT).show();
}
}
};
Signal Strength of Bluetooth devices using Web-Bluetooth
I recently implemented the watchAdvertisements()
API that will enable the page to listen for advertisement packets from the device. When a packet is received, an advertisementreceived
Event is fired on the device, and the Event contains the RSSI and TX Power of the device. You can give this API a try by enabling chrome://flags/#enable-experimental-web-platform-features in Chrome 85.0.4165 or higher.
Related Topics
Android and Getting a View with Id Cast as a String
Cannot Resolve Method Getmap()
How to Change the Edittext Text Without Triggering the Text Watcher
Convert Normal Java Array or Arraylist to JSON Array in Android
How to Get Selected Xls File Path from Uri for Sdk 17 or Below for Android
How to Wait for All Tasks in an Threadpoolexecutor to Finish Without Shutting Down the Executor
Portrait for Phone, Landscape for Tablet (Android-Layout)
What Is the Use of Memoryfile in Android
Unable to Compile Jni Program Rjava
How to Persist Permission in Android API 19 (Kitkat)