Class AccessibilityService

  • java.lang.Object

  • public class AccessibilityService
    extends java.lang.Object
    Encloses all the services needed to implement a custom accessibility system. Text-to-speech synthesis, sound and device vibration.
    • Constructor Detail

      • AccessibilityService

        public AccessibilityService(Context context)
        Constructs a new AccessibilityService.
        context - The current context
    • Method Detail

      • getInstance

        public static AccessibilityService getInstance(Context context)
        Creates an instance of AccessibilityService. It implements the singleton pattern, therefore successive calls to this method will always return the same object.
        context - The context to use. Usually your Application or Activity object.
        a singleton instance of AccessibilityService
      • loadSounds

        public void loadSounds()
        Loads the built in sound library. This method must be called before any call to playSound or stopSound.
      • playSound

        public void playSound(AccessibilityService.SoundEvent event,
                              boolean loop)
        Plays the sound associated to a SoundEvent.
        event - the event to play the sound of
        loop - whether to play the sound in a continuous loop or not
      • playSound

        public void playSound(AccessibilityService.SoundEvent event)
        Plays the sound associated to a SoundEvent once. This call is equivalent to playSound(event,false).
        event - the event to play the sound of
      • stopSound

        public void stopSound()
        Stop all the sounds being played at the moment of the call. Useful to stop a sound that is looping after a call to playSound(event,true).
      • speak

        public void speak(java.lang.String text)
        Utters a text via android text to speech synthesizer
        text - the string to be uttered
      • vibrate

        public void vibrate()
        Make the device vibrate
      • dispose

        public void dispose()
        Dispose the resources allocated during initialization. To be called when the class is no longer needed by client classes.