我想获得连接到手机的另一台设备的蓝牙信号强度,
如何获得蓝牙信号强度?
我试图在谷歌搜索很多,但没有找到任何答案.
有人知道我该如何实现它?
这是myActivity:
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
registerReceiver(receiver, new IntentFilter(BluetoothDevice.ACTION_FOUND));
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
private final BroadcastReceiver receiver = new BroadcastReceiver(){
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if(BluetoothDevice.ACTION_FOUND.equals(action)) {
int rssi = intent.getShortExtra(BluetoothDevice.EXTRA_RSSI,Short.MIN_VALUE);
Toast.makeText(getApplicationContext()," RSSI: " + rssi + …Run Code Online (Sandbox Code Playgroud) 在我的一个应用程序中,我需要显示与我的手机配对的所有wi-fi和蓝牙设备,以及它们的信号强度.有了wi-fi,我可以显示信号强度(RSSI).但我的蓝牙问题.我搜索了一些适合这项任务的方法; 我找到了一种方法:
intent.getShortExtra(BluetoothDevice.EXTRA_RSSI, Short.MIN_VALUE);
Run Code Online (Sandbox Code Playgroud)
但它只显示未与我的手机配对的新设备RSSI.是否有任何想法让所有蓝牙设备RSSI?