STWHeadsetManager

open class STWHeadsetManager

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')
     }
    
  • 
    STWHeadsetManager.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...
         }
    
         });
    
  • 
            STWHeadsetManager.getInstance().unregisterForHeadsetMediaButtonCallback(getContext());
    

Functions

Link copied to clipboard
open fun getInstance(): STWHeadsetManager
Link copied to clipboard
open fun registerATXEvent(@NonNull context: Context, @Nullable iHeadsetActionCallback: IHeadsetActionCallback)
Link copied to clipboard
open fun registerForHeadsetMediaButtonCallback(@NonNull context: Context, @Nullable iHeadsetActionCallback: IHeadsetActionCallback)
open fun registerForHeadsetMediaButtonCallback(    @NonNull context: Context,     isToggleModeDisabled: Boolean,     @Nullable iHeadsetActionCallback: IHeadsetActionCallback)
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)
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
open fun unregisterFroATXEventReceiver(@NonNull context: Context)
Call this method to unregister the ATXEventReciever