SampleSpellCheckerService
@Override public Session createSession() { return new AndroidSpellCheckerSession(); } private static class AndroidSpellCheckerSession extends Session { @Override public SuggestionsInfo onGetSuggestions(TextInfo textInfo, int suggestionsLimit) { SuggestionsInfo suggestionsInfo; ... // look up suggestions for TextInfo return suggestionsInfo; } }
textInfo
TextInfo
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.android.samplespellcheckerservice"> <application android:label="@string/app_name"> <service android:label="@string/app_name" android:name=".SampleSpellCheckerService" android:permission="android.permission.BIND_TEXT_SERVICE"> <intent-filter> <action android:name="android.service.textservice.SpellCheckerService" /> </intent-filter> <meta-data android:name="android.view.textservice.scs" android:resource="@xml/spellchecker" /> </service> </application> </manifest>
SpellCheckerSettingsActivity
<spell-checker xmlns:android="http://schemas.android.com/apk/res/android" android:label="@string/spellchecker_name" android:settingsactivity="com.example.SpellCheckerSettingsActivity" /> <subtype android:label="@string/subtype_generic" android:subtypeLocale="en" /> </spell-checker>
private static class AndroidSpellCheckerSession extends Session { @Override public SentenceSuggestionsInfo[] onGetSentenceSuggestionsMultiple( TextInfo[] textInfo, int suggestionsLimit) { SentenceSuggestionsInfo[] sentenceSuggestionsInfos; ... // look up suggestions for each TextInfo return sentenceSuggestionsInfos } }