Create Browser-Bookmark from app

前端 未结 2 1236
渐次进展
渐次进展 2020-12-09 14:01

I want to create a bookmark in the stock android-browser from my own application. How can I do this?

I only found the Browser.saveBookmark-Method (api-d

2条回答
  •  余生分开走
    2020-12-09 14:47

    If you just want to allow the user to add a bookmark, android.provider.Browser.saveBookmark() is what you want. But it looks like you're wanting to do mass updates, so that's probably not enough since it just opens the browser's bookmarks page.

    AFAIK there is no open API that ties directly into the browser's bookmarks. However, there is a content resolver for it which can be accessed android.provider.Browser.BOOKMARKS_URI. Once you've resolved the provider you can manipulate bookmarks by running queries, provided you have the com.android.browser.permission.READ_HISTORY_BOOKMARKS and com.android.browser.permission.WRITE_HISTORY_BOOKMARKS permissions.

    If you're unfamiliar with content providers, they can get kinda hairy (doubly so if you're unfamiliar with SQL). However, the knowledge base has some good articles on them, and a quick google for "android content provider tutorial" should get you well on your way.

提交回复
热议问题