chcę uzyskać siłę sygnału Bluetooth z innym urządzeniem, które łączy się z moim telefonem,Get siłę sygnału bluetooth
Jak mogę uzyskać siłę sygnału Bluetooth?
Próbowałem dużo wyszukiwać w google i nie znalazłem żadnej odpowiedzi.
Czy ktoś wie, jak mogę go wdrożyć?
to 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();
}
}
};
}
I posiada również zezwolenie Bluetooth w moim pliku manifestu.
http://stackoverflow.com/questions/3020407/how-to-find-signal-strength-ofected-bluetooth-devices –
Już to widziałem, jednak nie ma żadnego przykładu, jak znaleźć sygnał siła ... może mi pomożesz? –
Myślę, że twój kod jest OK. Aby zobaczyć Toast, musisz najpierw wykonać Discover. – Memochipan