Question

I am writing a Spell Check client using the sample code in the SDK as an example. I have the following code (not actual implementation, but an accurate sample representation):

public class HelloSpellChecker implements SpellCheckerSessionListener {
    private SpellCheckerSession mSpellCheckService;

    private void bindService() {
        final TextServicesManager tsm = (TextServicesManager) getSystemService(
            Context.TEXT_SERVICES_MANAGER_SERVICE);
        mSpellCheckService = tsm.newSpellCheckerSession(null, null, this, true);
    }        

    public void getSuggestions(String word) {
        mSpellCheckService.getSuggestions(new TextInfo("tgis"), 3);
    }

    @Override
    public void onGetSentenceSuggestions(final SentenceSuggestionsInfo[] arg0) {
        Log.d(TAG, "onGetSentenceSuggestions");
        // Process suggestions
    }
}

What I want to know is will onGetSentenceSuggestions only be fired when my application calls getSuggestions, or will it be fired any time the system service receives a request to getSuggestions?

If it is the latter, what is the best way to ensure my app only processes suggestions which it requested?

Was it helpful?

Solution

I would say Android system service listener is localized through the session in this case. onGetSentenceSuggestions method is fired by any request to getSuggestions method. However, you don't have to worry about processing suggestions which your app requested since the spellchecker session takes care of it. Your app only gets the suggestions requested by the session your app created to interact with the spell checker service. Hope this helps.

References:

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top