Get browser history and search result in android

前端 未结 2 495
野趣味
野趣味 2020-12-09 07:33

I am trying to get the history and search results from the android browser. In the following code I get all the bookmarks, which works great:

public void get         


        
2条回答
  •  失恋的感觉
    2020-12-09 07:49

    For some strange reason, Google decided to mix bookmarks and history calling them "Bookmarks" in the SDK. Try the following code, the important thing is to filter by "bookmark" type.

        String[] proj = new String[] { Browser.BookmarkColumns.TITLE, Browser.BookmarkColumns.URL };
        String sel = Browser.BookmarkColumns.BOOKMARK + " = 0"; // 0 = history, 1 = bookmark
        mCur = this.managedQuery(Browser.BOOKMARKS_URI, proj, sel, null, null);
        this.startManagingCursor(mCur);
        mCur.moveToFirst();
    
        String title = "";
        String url = "";
    
        if (mCur.moveToFirst() && mCur.getCount() > 0) {
            while (mCur.isAfterLast() == false && cont) {
    
                title = mCur.getString(mCur.getColumnIndex(Browser.BookmarkColumns.TITLE));
                url = mCur.getString(mCur.getColumnIndex(Browser.BookmarkColumns.URL));
                // Do something with title and url
    
                mCur.moveToNext();
            }
        }
    

提交回复
热议问题