在contentObserver中未触发Android onChange事件以获取android 5(Lollipop)上的Chrome历史记录 [英] Android onChange event not triggered in contentObserver for chrome history on android 5 (Lollipop)

查看:103
本文介绍了在contentObserver中未触发Android onChange事件以获取android 5(Lollipop)上的Chrome历史记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到我的Chrome历史记录和书签的contentObservers不再在android lolipop上触发.该代码在旧版本的android(无论chrome版本如何)上均可正常运行,但在Lollipop上则无法正常工作.

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.

我已经提交了一个关于铬的bug,其他人在评论中证实了这一点.

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: 感谢Fuong Lee的解决方法,请在添加内容观察器以快速启动它之后调用此方法:

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);
   }

推荐答案

当我将Chrome书签的新URI从"content://com.android.chrome.browser/bookmarks"更改为新URI"content://com"时.android.chrome.browser/history",相同的问题在Lolipop版本上未触发onChange事件".而且,我尝试在观察者注册后查询数据以进行检查...它运行得像魔术一样.我不知道为什么它可以正常运行,希望对您有所帮助.

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.

这篇关于在contentObserver中未触发Android onChange事件以获取android 5(Lollipop)上的Chrome历史记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆