android - How to receive notification regarding the BT connection states -
i trying receive notifications when connection state changed "connecting,connected,disonnectig,disconnected". registered action_connection_state_changed, receive log in "default" statement of "switch-case".
please let me know how receive notified correctly regarding states mentioned in switch-case in below code?
code:
final int connstate = intent.getintextra(bluetoothadapter.extra_connection_state, bluetoothadapter.error); switch (connstate) { case bluetoothadapter.state_connected: log.d(tag, logand.show("onreceive", "bluetoothadapter.state_connected")); tvstatus.settext("bt state_connected."); break; case bluetoothadapter.: log.d(tag, logand.show("onreceive", "bluetoothadapter.state_connected")); tvstatus.settext("bt state_connected."); break; case bluetoothadapter.state_connecting: log.d(tag, logand.show("onreceive", "bluetoothadapter.state_connecting")); tvstatus.settext("bt state_connecting."); break; case bluetoothadapter.state_disconnecting: log.d(tag, logand.show("onreceive", "bluetoothadapter.state_disconnecting")); tvstatus.settext("bt state_disconnecting."); break; case bluetoothadapter.state_disconnected: log.d(tag, logand.show("onreceive", "bluetoothadapter.state_disconnected")); tvstatus.settext("bt state_disconnected."); break; default: log.wtf(tag, logand.show("onreceive", "connstate: unhandeled case.")); break; } break;
you need
bluetoothadapter.extra_state
instead of
bluetoothadapter.extra_connection_state
Comments
Post a Comment