Aygıtın Bluetooth tarama modu değiştiğinde (örn. Keşfedilebilir/keşfedilemez) bir nesneyi Cordova'ya döndürmek için aşağıdaki kodu kullanıyorum.EXTRA_PREVIOUS_SCAN_MODE her zaman Android Bluetooth için bir hata döndürüyor
cordova.getActivity().getApplicationContext().registerReceiver(new BroadcastReceiver(){
@Override
public void onReceive(Context c,Intent intent){
JSONObject json=new JSONObject();
try{
json.put("current",intent.getIntExtra(BluetoothAdapter.EXTRA_SCAN_MODE,BluetoothAdapter.ERROR));
json.put("previous",intent.getIntExtra(BluetoothAdapter.EXTRA_PREVIOUS_SCAN_MODE,BluetoothAdapter.ERROR));
}catch(JSONException e){
}
PluginResult result=new PluginResult(PluginResult.Status.OK,json);
result.setKeepCallback(true);
discoverableCallback.sendPluginResult(result); // discoverableCallback is a callbackContext
}
},new IntentFilter(BluetoothAdapter.ACTION_SCAN_MODE_CHANGED));
Ancak intent.getIntExtra(BluetoothAdapter.EXTRA_PREVIOUS_SCAN_MODE,BluetoothAdapter.ERROR)
hep BluetoothAdapter.ERROR
olduğunu. Ardışık olarak birkaç kez açma ve kapama ayarlamayı denedim ve her zaman BluetoothAdapter.ERROR
. Önceki tarama modunu nasıl döndürürüm?
Ne ayrıştırma amacınız var? Anahtar Değer çiftlerini Yineleyici üzerinden yazdırmayı deneyin. – Cookster
Amaç, Bluetooth'u keşfedilebilir olarak ayarlamaktır (diğer aygıtlara göre). Hangi değişkenin anahtar/değer çiftlerini basarım? –
bu BluetoothAdapter.EXTRA_PREVIOUS_CONNECTION_STATE gerekli koşulda sizin için çalışmayacak mı? – pratz9999