SpellCheckerSessionpublic class SpellCheckerSession extends Object The SpellCheckerSession interface provides the per client functionality of SpellCheckerService.
Applications
In most cases, applications that are using the standard
{@link 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 {@link 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 {@link #getSuggestions(TextInfo, int)} or
{@link #getSuggestions(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, {@link 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
{@link android.service.textservice.SpellCheckerService} interface, via the
{@link 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.
|
Fields Summary |
---|
private static final String | TAG | private static final boolean | DBG | public static final String | SERVICE_META_DATAName under which a SpellChecker service component publishes information about itself.
This meta-data must reference an XML resource. | private static final int | MSG_ON_GET_SUGGESTION_MULTIPLE | private static final int | MSG_ON_GET_SUGGESTION_MULTIPLE_FOR_SENTENCE | private final InternalListener | mInternalListener | private final com.android.internal.textservice.ITextServicesManager | mTextServicesManager | private final android.view.textservice.SpellCheckerInfo | mSpellCheckerInfo | private final SpellCheckerSessionListenerImpl | mSpellCheckerSessionListenerImpl | private final SpellCheckerSubtype | mSubtype | private boolean | mIsUsed | private SpellCheckerSessionListener | mSpellCheckerSessionListener | private final android.os.Handler | mHandlerHandler that will execute the main tasks |
Methods Summary |
---|
public void | cancel()Cancel pending and running spell check tasks
mSpellCheckerSessionListenerImpl.cancel();
| public void | close()Finish this session and allow TextServicesManagerService to disconnect the bound spell
checker.
mIsUsed = false;
try {
mSpellCheckerSessionListenerImpl.close();
mTextServicesManager.finishSpellCheckerService(mSpellCheckerSessionListenerImpl);
} catch (RemoteException e) {
// do nothing
}
| protected void | finalize()
super.finalize();
if (mIsUsed) {
Log.e(TAG, "SpellCheckerSession was not finished properly." +
"You should call finishShession() when you finished to use a spell checker.");
close();
}
| public void | getSentenceSuggestions(android.view.textservice.TextInfo[] textInfos, int suggestionsLimit)Get suggestions from the specified sentences
mSpellCheckerSessionListenerImpl.getSentenceSuggestionsMultiple(
textInfos, suggestionsLimit);
| public android.view.textservice.SpellCheckerInfo | getSpellChecker()Get the spell checker service info this spell checker session has.
return mSpellCheckerInfo;
| public com.android.internal.textservice.ISpellCheckerSessionListener | getSpellCheckerSessionListener()
return mSpellCheckerSessionListenerImpl;
| public void | getSuggestions(android.view.textservice.TextInfo textInfo, int suggestionsLimit)Get candidate strings for a substring of the specified text.
getSuggestions(new TextInfo[] {textInfo}, suggestionsLimit, false);
| public void | getSuggestions(android.view.textservice.TextInfo[] textInfos, int suggestionsLimit, boolean sequentialWords)A batch process of getSuggestions
if (DBG) {
Log.w(TAG, "getSuggestions from " + mSpellCheckerInfo.getId());
}
mSpellCheckerSessionListenerImpl.getSuggestionsMultiple(
textInfos, suggestionsLimit, sequentialWords);
| public com.android.internal.textservice.ITextServicesSessionListener | getTextServicesSessionListener()
return mInternalListener;
| private void | handleOnGetSentenceSuggestionsMultiple(SentenceSuggestionsInfo[] suggestionInfos)
mSpellCheckerSessionListener.onGetSentenceSuggestions(suggestionInfos);
| private void | handleOnGetSuggestionsMultiple(android.view.textservice.SuggestionsInfo[] suggestionInfos)
mSpellCheckerSessionListener.onGetSuggestions(suggestionInfos);
| public boolean | isSessionDisconnected()
return mSpellCheckerSessionListenerImpl.isDisconnected();
|
|