The first three deal primarily with language management, and are used to
query the engine for it's support for a given language and indicate to it
that requests in a given language are imminent.
onSynthesizeText(SynthesisRequest, SynthesisCallback) is central to the engine implementation. The
implementation should synthesize text as per the request parameters and
return synthesized data via the supplied callback. This class and its helpers
will then consume that data, which might mean queuing it for playback or writing
it to a file or similar. All calls to this method will be on a single thread,
which will be different from the main thread of the service. Synthesis must be
synchronous which means the engine must NOT hold on to the callback or call any
methods on it after the method returns.
onStop() tells the engine that it should stop
all ongoing synthesis, if any. Any pending data from the current synthesis
will be discarded.
onGetLanguage() is not required as of JELLYBEAN_MR2 (API 18) and later, it is only
called on earlier versions of Android.
API Level 20 adds support for Voice objects. Voices are an abstraction that allow the TTS
service to expose multiple backends for a single locale. Each one of them can have a different
features set. In order to fully take advantage of voices, an engine should implement
the following methods:

Flag for bindService(Intent, ServiceConnection, int): If binding from an activity, allow the
target service's process importance to be raised based on whether the
activity is visible to the user, regardless whether another flag is
used to reduce the amount that the client process's overall importance
is used to impact it.

This constant was deprecated
in API level 17.
Creating world-readable files is very dangerous, and likely
to cause security holes in applications. It is strongly discouraged;
instead, applications should use more formal mechanism for interactions
such as ContentProvider, BroadcastReceiver, and
Service. There are no guarantees that this
access mode will remain on a file, such as when it goes through a
backup and restore.
File creation mode: allow all other applications to have read access
to the created file.

This constant was deprecated
in API level 17.
Creating world-writable files is very dangerous, and likely
to cause security holes in applications. It is strongly discouraged;
instead, applications should use more formal mechanism for interactions
such as ContentProvider, BroadcastReceiver, and
Service. There are no guarantees that this
access mode will remain on a file, such as when it goes through a
backup and restore.
File creation mode: allow all other applications to have write access
to the created file.

Level for onTrimMemory(int): the process is around the middle
of the background LRU list; freeing memory can help the system keep
other processes running later in the list for better overall performance.

Level for onTrimMemory(int): the process is not an expendable
background process, but the device is running extremely low on memory
and is about to not be able to keep any background processes running.

This method is deprecated.
Sticky broadcasts should not be used. They provide no security (anyone
can access them), no protection (anyone can modify them), and many other problems.
The recommended pattern is to use a non-sticky broadcast to report that something
has changed, with another mechanism for apps to retrieve the current value whenever
desired.

This method is deprecated.
Sticky broadcasts should not be used. They provide no security (anyone
can access them), no protection (anyone can modify them), and many other problems.
The recommended pattern is to use a non-sticky broadcast to report that something
has changed, with another mechanism for apps to retrieve the current value whenever
desired.

Broadcast the given intent to all interested BroadcastReceivers, delivering
them one at a time to allow more preferred receivers to consume the
broadcast before it is delivered to less preferred receivers.

This method is deprecated.
Sticky broadcasts should not be used. They provide no security (anyone
can access them), no protection (anyone can modify them), and many other problems.
The recommended pattern is to use a non-sticky broadcast to report that something
has changed, with another mechanism for apps to retrieve the current value whenever
desired.

This method is deprecated.
Sticky broadcasts should not be used. They provide no security (anyone
can access them), no protection (anyone can modify them), and many other problems.
The recommended pattern is to use a non-sticky broadcast to report that something
has changed, with another mechanism for apps to retrieve the current value whenever
desired.

This method is deprecated.
Sticky broadcasts should not be used. They provide no security (anyone
can access them), no protection (anyone can modify them), and many other problems.
The recommended pattern is to use a non-sticky broadcast to report that something
has changed, with another mechanism for apps to retrieve the current value whenever
desired.

This method is deprecated.
Sticky broadcasts should not be used. They provide no security (anyone
can access them), no protection (anyone can modify them), and many other problems.
The recommended pattern is to use a non-sticky broadcast to report that something
has changed, with another mechanism for apps to retrieve the current value whenever
desired.

This method was deprecated
in API level 21.
Sticky broadcasts should not be used. They provide no security (anyone
can access them), no protection (anyone can modify them), and many other problems.
The recommended pattern is to use a non-sticky broadcast to report that something
has changed, with another mechanism for apps to retrieve the current value whenever
desired.

This method was deprecated
in API level 21.
Sticky broadcasts should not be used. They provide no security (anyone
can access them), no protection (anyone can modify them), and many other problems.
The recommended pattern is to use a non-sticky broadcast to report that something
has changed, with another mechanism for apps to retrieve the current value whenever
desired.

Broadcast the given intent to all interested BroadcastReceivers, delivering
them one at a time to allow more preferred receivers to consume the
broadcast before it is delivered to less preferred receivers.

This method was deprecated
in API level 21.
Sticky broadcasts should not be used. They provide no security (anyone
can access them), no protection (anyone can modify them), and many other problems.
The recommended pattern is to use a non-sticky broadcast to report that something
has changed, with another mechanism for apps to retrieve the current value whenever
desired.

This method was deprecated
in API level 21.
Sticky broadcasts should not be used. They provide no security (anyone
can access them), no protection (anyone can modify them), and many other problems.
The recommended pattern is to use a non-sticky broadcast to report that something
has changed, with another mechanism for apps to retrieve the current value whenever
desired.

This method was deprecated
in API level 21.
Sticky broadcasts should not be used. They provide no security (anyone
can access them), no protection (anyone can modify them), and many other problems.
The recommended pattern is to use a non-sticky broadcast to report that something
has changed, with another mechanism for apps to retrieve the current value whenever
desired.

This method was deprecated
in API level 21.
Sticky broadcasts should not be used. They provide no security (anyone
can access them), no protection (anyone can modify them), and many other problems.
The recommended pattern is to use a non-sticky broadcast to report that something
has changed, with another mechanism for apps to retrieve the current value whenever
desired.

Public Constructors

public
TextToSpeechService()

Public Methods

Return the communication channel to the service. May return null if
clients can not bind to the service. The returned
IBinder is usually for a complex interface
that has been described using
aidl.

Note that unlike other application components, calls on to the
IBinder interface returned here may not happen on the main thread
of the process. More information about the main thread can be found in
Processes and
Threads.

Parameters

intent

The Intent that was used to bind to this service,
as given to Context.bindService. Note that any extras that were included with
the Intent at that point will not be seen here.

Returns

Return an IBinder through which clients can call on to the
service.

public
void
onCreate()

public
void
onDestroy()

Called by the system to notify a Service that it is no longer used and is being removed. The
service should clean up any resources it holds (threads, registered
receivers, etc) at this point. Upon return, there will be no more calls
in to this Service object and it is effectively dead. Do not call this method directly.

Return a name of the default voice for a given locale.
This method provides a mapping between locales and available voices. This method is
used in setLanguage(Locale), which calls this method and then calls
setVoice(Voice) with the voice returned by this method.
Also, it's used by getDefaultVoice() to find a default voice for
the default locale.

Parameters

lang

ISO-3 language code.

country

ISO-3 country code. May be empty or null.

variant

Language variant. May be empty or null.

Returns

Queries the service for a set of supported voices.
Can be called on multiple threads.
The default implementation tries to enumerate all available locales, pass them to
onIsLanguageAvailable(String, String, String) and create Voice instances (using
the locale's BCP-47 language tag as the voice name) for the ones that are supported.
Note, that this implementation is suitable only for engines that don't have multiple voices
for a single locale. Also, this implementation won't work with Locales not listed in the
set returned by the getAvailableLocales() method.

Returns

Checks whether the engine supports a voice with a given name.
Can be called on multiple threads.
The default implementation treats the voice name as a language tag, creating a Locale from
the voice name, and passes it to onIsLanguageAvailable(String, String, String).

Parameters

voiceName

Name of the voice.

Returns

Notifies the engine that it should load a speech synthesis voice. There is no guarantee
that this method is always called before the voice is used for synthesis. It is merely
a hint to the engine that it will probably get some synthesis requests for this voice
at some point in the future.
Will be called only on synthesis thread.
The default implementation creates a Locale from the voice name (by interpreting the name as
a BCP-47 tag for the locale), and passes it to
onLoadLanguage(String, String, String).

Returns

Returns the language, country and variant currently being used by the TTS engine.
This method will be called only on Android 4.2 and before (API <= 17). In later versions
this method is not called by the Android TTS framework.
Can be called on multiple threads.

Returns

A 3-element array, containing language (ISO 3-letter code),
country (ISO 3-letter code) and variant used by the engine.
The country and variant may be "". If country is empty, then variant must
be empty too.

Notifies the engine that it should load a speech synthesis language. There is no guarantee
that this method is always called before the language is used for synthesis. It is merely
a hint to the engine that it will probably get some synthesis requests for this language
at some point in the future.
Can be called on multiple threads.
In <= Android 4.2 (<= API 17) can be called on main and service binder threads.
In > Android 4.2 (> API 17) can be called on main and synthesis threads.

protected
abstract
void
onStop()

Notifies the service that it should stop any in-progress speech synthesis.
This method can be called even if no speech synthesis is currently in progress.
Can be called on multiple threads, but not on the synthesis thread.