STWHeadset Manager
STWHeadsetManager
Description :
Public Class which handles hardware buttons actions for standard headsets and some bluetooth or wired headsets that works with AtX event using broadcast receivers. The action handled for standard headset is the click performed on media button, and the actions handled for headsets using AtX event are the click down (press) and click up (release) on SOS and PTT buttons. The long click event is not detected for a standard headset because of event is catched from device to open for example google voice or any other recognizing voice application.
Example of use
To add the Support of SWhardware module to your project, include the following line in the dependencies block of your build.gradle file:dependencies { implementation project(':swhardware') }Content copied to clipboardContent copied to clipboardSTWHeadsetManager.getInstance().registerForHeadsetMediaButtonCallback(getContext(), new IHeadsetActionCallback() { public boolean shouldHandleActions() { //Code... (return true or false to block/unblock reception of callbacks) return true; } public void onHeadsetMediaButtonClicked() { //Code... } public void onHeadsetButtonPressed() { //Code... } public void onHeadsetButtonReleased() { //Code... } public void onHeadsetSosButtonPressed() { //Code... } public void onHeadsetSosButtonReleased() { //Code... } });Content copied to clipboardSTWHeadsetManager.getInstance().unregisterForHeadsetMediaButtonCallback(getContext());Content copied to clipboard
Functions
Link copied to clipboard
Link copied to clipboard
open fun registerATXEvent(@NonNull context: Context, @Nullable iHeadsetActionCallback: IHeadsetActionCallback)
Content copied to clipboard
Link copied to clipboard
Content copied to clipboard
open fun registerForHeadsetMediaButtonCallback( @NonNull context: Context, isToggleModeDisabled: Boolean, @Nullable iHeadsetActionCallback: IHeadsetActionCallback)
Content copied to clipboard
Call this method to register for events related to click on headset media button event (standard headset and headset working with AtX events)
Link copied to clipboard
open fun unregisterForHeadsetMediaButtonCallback(@NonNull context: Context)
Content copied to clipboard
Call this method to unregister from events related to click on headset media button event (standard headset and headset working with AtX events)
Link copied to clipboard
Call this method to unregister the ATXEventReciever