Class AccessibilityService
- java.lang.Object
-
- uk.ac.qmul.eecs.ccmi.accessibility.AccessibilityService
-
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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static class
AccessibilityService.SoundEvent
A list of events that have a sound associated.
-
Constructor Summary
Constructors Constructor and Description AccessibilityService(Context context)
Constructs a newAccessibilityService
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description void
dispose()
Dispose the resources allocated during initialization.static AccessibilityService
getInstance(Context context)
Creates an instance ofAccessibilityService
.void
loadSounds()
Loads the built in sound library.void
playSound(AccessibilityService.SoundEvent event)
Plays the sound associated to aSoundEvent
once.void
playSound(AccessibilityService.SoundEvent event, boolean loop)
Plays the sound associated to aSoundEvent
.void
speak(java.lang.String text)
Utters a text via android text to speech synthesizervoid
stopSound()
Stop all the sounds being played at the moment of the call.void
vibrate()
Make the device vibrate
-
-
-
Constructor Detail
-
AccessibilityService
public AccessibilityService(Context context)
Constructs a newAccessibilityService
.- Parameters:
context
- The current context
-
-
Method Detail
-
getInstance
public static AccessibilityService getInstance(Context context)
Creates an instance ofAccessibilityService
. It implements the singleton pattern, therefore successive calls to this method will always return the same object.- Parameters:
context
- The context to use. Usually yourApplication
orActivity
object.- Returns:
- a singleton instance of
AccessibilityService
-
loadSounds
public void loadSounds()
Loads the built in sound library. This method must be called before any call toplaySound
orstopSound
.
-
playSound
public void playSound(AccessibilityService.SoundEvent event, boolean loop)
Plays the sound associated to aSoundEvent
.- Parameters:
event
- the event to play the sound ofloop
- whether to play the sound in a continuous loop or not
-
playSound
public void playSound(AccessibilityService.SoundEvent event)
Plays the sound associated to aSoundEvent
once. This call is equivalent toplaySound(event,false)
.- Parameters:
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 toplaySound(event,true)
.
-
speak
public void speak(java.lang.String text)
Utters a text via android text to speech synthesizer- Parameters:
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.
-
-