我想它连接到我的电话的另一设备的蓝牙信号强度,获取蓝牙信号强度
我怎样才能获得蓝牙信号强度?
我试图搜索很多谷歌,并没有找到任何答案。
有人知道我该如何实现它吗?
这是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 + "dBm", Toast.LENGTH_SHORT).show();
}
}
};
}
我也有我的清单文件蓝牙权限。
http://stackoverflow.com/questions/3020407/how-to-find-signal-strength-of-connected-bluetooth-devices – 2013-03-09 16:13:18
我已经看到它,但是没有任何如何找到信号的例子力量..可能你能帮助我吗? – 2013-03-09 16:14:57
我认为你的代码是好的。为了查看Toast,您需要先执行Discover。 – Memochipan 2013-08-04 22:40:03