SpellCheckerSession
open class SpellCheckerSession
kotlin.Any | |
↳ | android.view.textservice.SpellCheckerSession |
The SpellCheckerSession interface provides the per client functionality of SpellCheckerService.
Applications
In most cases, applications that are using the standard android.widget.TextView
or its subclasses will have little they need to do to work well with spell checker services. The main things you need to be aware of are:
- Properly set the
android.R.attr#inputType
in your editable text views, so that the spell checker will have enough context to help the user in editing text in them.
For the rare people amongst us writing client applications that use the spell checker service directly, you will need to use getSuggestions(android.view.textservice.TextInfo,int)
or getSuggestions(android.view.textservice.TextInfo[],int,boolean)
for obtaining results from the spell checker service by yourself.
Security
There are a lot of security issues associated with spell checkers, since they could monitor all the text being sent to them through, for instance, android.widget.TextView
. The Android spell checker framework also allows arbitrary third party spell checkers, so care must be taken to restrict their selection and interactions.
Here are some key points about the security architecture behind the spell checker framework:
- Only the system is allowed to directly access a spell checker framework's
android.service.textservice.SpellCheckerService
interface, via theandroid.Manifest.permission#BIND_TEXT_SERVICE
permission. This is enforced in the system by not binding to a spell checker service that does not require this permission. - The user must explicitly enable a new spell checker in settings before they can be enabled, to confirm with the system that they know about it and want to make it available for use.
Summary
Nested classes | |
---|---|
abstract |
Callback for getting results from text services |
open |
Parameters used to create a |
Constants | |
---|---|
static String |
Name under which a SpellChecker service component publishes information about itself. |
Public methods | |
---|---|
open Unit |
cancel() Cancel pending and running spell check tasks |
open Unit |
close() Finish this session and allow TextServicesManagerService to disconnect the bound spell checker. |
open Unit |
getSentenceSuggestions(textInfos: Array<TextInfo!>!, suggestionsLimit: Int) Get suggestions from the specified sentences |
open SpellCheckerInfo! |
Get the spell checker service info this spell checker session has. |
open Unit |
getSuggestions(textInfo: TextInfo!, suggestionsLimit: Int) Get candidate strings for a substring of the specified text. |
open Unit |
getSuggestions(textInfos: Array<TextInfo!>!, suggestionsLimit: Int, sequentialWords: Boolean) A batch process of getSuggestions |
open Boolean |
Protected methods | |
---|---|
open Unit |
finalize() |
Constants
SERVICE_META_DATA
static val SERVICE_META_DATA: String
Name under which a SpellChecker service component publishes information about itself. This meta-data must reference an XML resource.
Value: "android.view.textservice.scs"
Public methods
close
open fun close(): Unit
Finish this session and allow TextServicesManagerService to disconnect the bound spell checker.
getSentenceSuggestions
open fun getSentenceSuggestions(
textInfos: Array<TextInfo!>!,
suggestionsLimit: Int
): Unit
Get suggestions from the specified sentences
Parameters | |
---|---|
textInfos |
Array<TextInfo!>!: an array of text metadata for a spell checker |
suggestionsLimit |
Int: the maximum number of suggestions that will be returned |
getSpellChecker
open fun getSpellChecker(): SpellCheckerInfo!
Get the spell checker service info this spell checker session has.
Return | |
---|---|
SpellCheckerInfo! |
SpellCheckerInfo for the specified locale. |
getSuggestions
open fungetSuggestions(
textInfo: TextInfo!,
suggestionsLimit: Int
): Unit
Deprecated: use SpellCheckerSession#getSentenceSuggestions(TextInfo[], int)
instead
Get candidate strings for a substring of the specified text.
Parameters | |
---|---|
textInfo |
TextInfo!: text metadata for a spell checker |
suggestionsLimit |
Int: the maximum number of suggestions that will be returned |
getSuggestions
open fungetSuggestions(
textInfos: Array<TextInfo!>!,
suggestionsLimit: Int,
sequentialWords: Boolean
): Unit
Deprecated: use SpellCheckerSession#getSentenceSuggestions(TextInfo[], int)
instead
A batch process of getSuggestions
Parameters | |
---|---|
textInfos |
Array<TextInfo!>!: an array of text metadata for a spell checker |
suggestionsLimit |
Int: the maximum number of suggestions that will be returned |
sequentialWords |
Boolean: true if textInfos can be treated as sequential words. |
isSessionDisconnected
open fun isSessionDisconnected(): Boolean
Return | |
---|---|
Boolean |
true if the connection to a text service of this session is disconnected and not alive. |
Protected methods
finalize
protected open fun finalize(): Unit
Exceptions | |
---|---|
java.lang.Throwable |
the Exception raised by this method |