1

can i get url what i write on android device browser..

please tell me..

thanks.

1
  • Have you already tried to load that page or just written that in the url field? I mean do you need url of the page that was just loaded? Commented Apr 20, 2011 at 13:59

2 Answers 2

4

You can acces Browsing history the same way you do that for other ContentProviders. Besides browsing history you can also get list of Bookmarks. HISTORY_PROJECTION_BOOKMARK_INDEX is used to distinguish among them. You need permission com.android.browser.permission.READ_HISTORY_BOOKMARKS to execute this code.

Cursor webLinksCursor = getContentResolver().query(Browser.BOOKMARKS_URI, Browser.HISTORY_PROJECTION, null, null, Browser.BookmarkColumns.DATE + " DESC");
int row_count = webLinksCursor.getCount();

int title_column_index = webLinksCursor.getColumnIndexOrThrow(Browser.BookmarkColumns.TITLE);
int url_column_index = webLinksCursor.getColumnIndexOrThrow(Browser.BookmarkColumns.URL);

if ((title_column_index > -1) && (url_column_index > -1) && (row_count > 0))
{
    webLinksCursor.moveToFirst();
    while (webLinksCursor.isAfterLast() == false)
    {
        if (webLinksCursor.getInt(Browser.HISTORY_PROJECTION_BOOKMARK_INDEX) != 1)
        {
            if (!webLinksCursor.isNull(url_column_index))
            {
                Log.i("History" , "Last page browsed " + webLinksCursor.getString(url_column_index));
                break;
            }
        }
        webLinksCursor.moveToNext();
    }            
}
webLinksCursor.close();
Sign up to request clarification or add additional context in comments.

Comments

0

My instinct tells me this is akin to reading the history, I can't see google allowing apps to access this data, it would be abused by malicious applications. However, if someone proves me wrong I'll be chosing my apps far more selectively in future!!

3 Comments

It is possible to fetch browsing history (just read). I will show you how just if Hari confirms this is what he expects.
Browsing history is available through ContentProvider, as you may see from the answer I posted. However, when installing some application you can see if that application approaches browsing History and avoid installation if that is not something you would expect from such an application.
Access to the Browsing history is allowed to enable creation of your custom Web browser application.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.