小编Ida*_*mim的帖子

获得蓝牙信号强度

我想获得连接到手机的另一台设备的蓝牙信号强度,

如何获得蓝牙信号强度?

我试图在谷歌搜索很多,但没有找到任何答案.

有人知道我该如何实现它?

这是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)

java android

32
推荐指数
4
解决办法
6万
查看次数

标签 统计

android ×1

java ×1