我可以通过以下代码从默认浏览器中获取搜索关键字。
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");
我正在寻找Uri of Chrome以获取搜索关键字。你知道它是什么吗?感谢
答案 0 :(得分:0)
List<SearchRecord> searchList = new LinkedList<SearchRecord>();
ContentResolver resolver = this.getContentResolver();
Cursor cursor = resolver.query(Browser.SEARCHES_URI, Browser.SEARCHES_PROJECTION, ***Browser.BookmarkColumns.BOOKMARK+ " = 0"***, 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();
}
}