简体   繁体   English

如何监听UserDictionary ContentProvider的更改?

[英]How to listen for changes to the UserDictionary ContentProvider?

I've implemented a spelling checker for ICS/JB. 我已经为ICS / JB实现了拼写检查。 The SpellingCheckerService.Session lets me set the suggestions in the popup menu that appears when you press a misspelled word (underlined in red) but doesn't notify me when the user presses "Add to Dictionary". SpellingCheckerService.Session允许我在按下拼写错误的单词(红色下划线)时出现的弹出菜单中设置建议,但在用户按“添加到词典”时不通知我。 It just adds it to the Android user dictionary, so my spelling checker will keep reporting that word as a typo. 它只是将其添加到Android用户词典中,因此我的拼写检查器会继续将该词报告为拼写错误。

I could query the user dictionary frequently but that is incredibly inefficient, especially since I'm not even notified if the menu opened. 我可以经常查询用户词典,但效率非常低,特别是因为菜单打开后我甚至都没有收到通知。

Is there a way to listen for changes to the UserDictionary, which is a system ContentProvider? 有没有办法监听UserDictionary的更改,这是一个系统ContentProvider? Better yet, is there a way to get notified when the user pressed "Add to Dictionary"? 更好的是,当用户按下“添加到词典”时,有没有办法得到通知?

您应该能够在UserDisctionary.CONTENT_URI上设置ContentObserver并获得更改通知。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM