我想获得连接到手机的另一台设备的蓝牙信号强度,
如何获得蓝牙信号强度?
我试图在谷歌搜索很多,但没有找到任何答案.
有人知道我该如何实现它?
这是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) 我有一个关于Android上的蓝牙RSSI功能的问题(2.0或2.1):
创建蓝牙连接时,很容易获得RSSI值,但是如何重复获取已经激活的连接的RSSI值?能够做到这一点非常重要,因为这可以让你确定蓝牙设备是否彼此接近或相距很远,但我在Android API中找不到任何适当的函数调用.
知道Android RSSI的人可以帮我解决这个问题吗?
谢谢!
亚历克斯