Added in API level 14

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 the android.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 SpellCheckerSession.

Constants
static String

Name under which a SpellChecker service component publishes information about itself.

Public methods
open Unit

Cancel pending and running spell check tasks

open Unit

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

Constants

SERVICE_META_DATA

Added in API level 14
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

cancel

Added in API level 15
open fun cancel(): Unit

Cancel pending and running spell check tasks

close

Added in API level 14
open fun close(): Unit

Finish this session and allow TextServicesManagerService to disconnect the bound spell checker.

getSentenceSuggestions

Added in API level 16
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

Added in API level 14
open fun getSpellChecker(): SpellCheckerInfo!

Get the spell checker service info this spell checker session has.

Return
SpellCheckerInfo! SpellCheckerInfo for the specified locale.

getSuggestions

Added in API level 14
Deprecated in API level 16
open fun getSuggestions(
    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

Added in API level 14
Deprecated in API level 16
open fun getSuggestions(
    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

Added in API level 14
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

Added in API level 14
protected open fun finalize(): Unit
Exceptions
java.lang.Throwable the Exception raised by this method