0
我可以通過以下代碼從默認瀏覽器中獲取搜索關鍵字。Android,如何從Chrome瀏覽器(Search Uri)搜索關鍵字?
List<SearchRecord> searchList = new LinkedList<SearchRecord>();
ContentResolver resolver = this.getContentResolver();
Cursor cursor = resolver.query(Browser.SEARCHES_URI, Browser.SEARCHES_PROJECTION, null, null, null);
cursor.moveToFirst();
if (cursor.moveToFirst() && cursor.getCount() > 0) {
while (cursor.isAfterLast() == false) {
SearchRecord record = new SearchRecord();
record.setKeyword(cursor.getString(Browser.SEARCHES_PROJECTION_SEARCH_INDEX));
record.setDate(cursor.getLong(Browser.SEARCHES_PROJECTION_DATE_INDEX));
searchList.add(record);
cursor.moveToNext();
}
}
下面的代碼返回書籤
Uri uriCustom = Uri.parse("content://com.android.chrome.browser/bookmarks");
我爲了得到搜索的關鍵字尋找Chrome瀏覽器開放的名單。你知道它是什麼嗎?由於
我認爲這將有利於http://stackoverflow.com/a/16609205/942224 –
感謝SANKET,我看到了在這之前的答案,但它不涉及到我的問題。該返回默認瀏覽器的書籤。我在尋找Chrome瀏覽器的搜索關鍵字。 – Hesam
我不確定,但您也可以從那裏獲得搜索記錄。 –