How to get browser history on android version > 23 programmatically?

独自空忆成欢 提交于 2020-01-06 18:58:27

问题


As we can see browser API is removed from android version > 23, so is there any other method to get browser history with user's permission? Thanks in advance.


回答1:


Contrary to the cited documentation, com.android.browser.permission.READ_HISTORY_BOOKMARKS is still defined by the framework, and can still be obtained by apps. Unfortunately, on Marshmallow and later, Chrome checks for a different permission, one that regular apps aren't allowed to obtain. For compatibility reasons, when that permission check inevitably fails, Chrome returns zero rows instead of throwing a SecurityException.

You can see the source code here:

query() calls hasReadAccess(), which calls hasPermission("com.android.browser.permission.READ_HISTORY_BOOKMARKS"), which on API >= M ignores the permission argument and instead checks for com.android.chrome.permission.READ_WRITE_BOOKMARK_FOLDERS. This permission is limited to system apps and apps signed with Google's key.

https://developer.android.com/about/versions/marshmallow/android-6.0-changes.html#behavior-bookmark-browser



来源:https://stackoverflow.com/questions/42502148/how-to-get-browser-history-on-android-version-23-programmatically

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