获取最后访问的URL在Chrome和其他浏览器 [英] Get Last Visited URL in Chrome and other browser's

查看:574
本文介绍了获取最后访问的URL在Chrome和其他浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想最后得到访问的URL在Chrome和其他浏览器。我能得到最后的URL在Android原生浏览器。我用下面的code本 -

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

但是,这code不会对其他浏览器的Chrome浏览器一样工作。我怎样才能得到最后访问的URL在Chrome和其他浏览器。

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

在此先感谢。

推荐答案

有关Chrome浏览器,你可以使用这个网址:

For chrome, you can use this uri:

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

有关URL和日期的列名是相同的:URL和日期

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

有关其他浏览器,因为它是说此处,有没有共同的解决方案和可能,BOOKMARKS_URI将无法正常工作。

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

这篇关于获取最后访问的URL在Chrome和其他浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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