我正在使用 SDK 中的示例代码作为示例编写拼写检查客户端。我有以下代码(不是实际实现,而是准确的示例表示):
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
}
}
我想知道的是onGetSentenceSuggestions
只会在我的应用程序调用时触发getSuggestions
,还是会在系统服务收到请求时触发getSuggestions
?
如果是后者,确保我的应用只处理它请求的建议的最佳方法是什么?