我想它連接到我的電話的另一設備的藍牙信號強度,獲取藍牙信號強度
我怎樣才能獲得藍牙信號強度?
我試圖搜索很多谷歌,並沒有找到任何答案。
有人知道我該如何實現它嗎?
這是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