我註冊了ACTION_BOND_STATE_CHANGED的藍牙,並且當我運行該應用程序時,switch-case語句中的非情況執行,而我收到的 是一個整數值,如下所示我不知道它的意義。意圖返回的整數沒有對應的常量值
我怎麼解釋它?
代碼:
int currBondState = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, BluetoothDevice.ERROR);
Log.d(TAG, LogAnd.show("onReceive", "currBondState: "+currBondState));
switch (currBondState) {
case BluetoothDevice.BOND_BONDING:
Log.d(TAG, LogAnd.show("onReceive", "currBondState: BOND_BONDING"));
tvStatus.setText("currBondState:BOND_BONDING");
break;
case BluetoothDevice.BOND_BONDED:
Log.d(TAG, LogAnd.show("onReceive", "currBondState: BOND_BONDED"));
tvStatus.setText("currBondState:BOND_BONDED");
break;
case BluetoothDevice.BOND_NONE:
Log.d(TAG, LogAnd.show("onReceive", "currBondState: BOND_NONE"));
tvStatus.setText("currBondState:BOND_NONE");
break;
}
08-25 17:16:06.803: D/MainActivity(22326): -> onReceive:currBondState: -2147483648
08-25 17:16:06.803: D/MainActivity(22326): -> onReceive:prevBondState: -2147483648
權限和我收到的價值之間的關係是什麼? – rmaik
由於adelphus說您收到錯誤值,因爲getextra不存在。 Als檢查intent.getAction,如果您收到的確實是債券變更響應。 –