Android onChange event not triggered in contentObserver for chrome history on android 5 (Lollipop)

一笑奈何 提交于 2019-12-21 19:57:11

问题


I've noticed that my contentObservers for chrome history and bookmarks do not trigger anymore on android lolipop. The code works perfectly on older versions of android (regardless of the chrome version) but on Lollipop it is not working anymore.

I've filed a bug on chromium and this is confirmed by others in the comments. https://code.google.com/p/chromium/issues/detail?q=obogzch%40gmail.com&colspec=ID%20Pri%20M%20Iteration%20ReleaseBlock%20Cr%20Status%20Owner%20Summary%20OS%20Modified&id=435541&thanks=435541&ts=1416575883

Did anybody found a solution to this?

LE: Thanks Fuong Lee for the workaround, call this method after you add the content observer to jump start it:

private boolean checkContentProvider(Uri uri) //uri = content://com.android.chrome.browser/history

   {
        Cursor mCur = getContentResolver().query(uri, null, null, null, null);
        return (mCur.getCount() > 0);
   }

回答1:


When I change new URI for chrome bookmarks from "content://com.android.chrome.browser/bookmarks" to new URI "content://com.android.chrome.browser/history", the same issue "onChange event not triggered on Lolipop version". And, I try query data to check after observer registered... it running like a magic. I don't know why it running correctly, hope it help.



来源:https://stackoverflow.com/questions/27044026/android-onchange-event-not-triggered-in-contentobserver-for-chrome-history-on-an

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!