Get Last Visited URL in Chrome and other browser's

一笑奈何 提交于 2020-03-13 05:27:20

问题


I want to get last visited URL in chrome and other browser's. I am able to get Last URL in android Native browser. I use following code for this -

Cursor cur = getContentResolver().query(Browser.BOOKMARKS_URI,
            new String[] { Browser.BookmarkColumns.URL }, null, null,
            BookmarkColumns.DATE + " DESC");
    if (cur != null && cur.getCount() > 0) {
        cur.moveToFirst();
        String url = cur.getString(cur
                .getColumnIndex(Browser.BookmarkColumns.URL));
        cur.close();
        return url;
    } else {
        if (cur != null) {
            cur.close();
        }
        return null;
    }

But this code does not work on other browser's like chrome. How can I get Last visited url in chrome and other browsers.

Thanks in advance.


回答1:


For chrome, you can use this uri:

Uri chromeUri = Uri.parse("content://com.android.chrome.browser/bookmarks");

Column names for URL and date are the same: "url" and "date".

For other browsers, as it is said here, there is no common solution and, probably, BOOKMARKS_URI won't work.



来源:https://stackoverflow.com/questions/20465266/get-last-visited-url-in-chrome-and-other-browsers

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