通过编程方式获取Android 23以上版本的浏览器历史记录,可以使用以下步骤:
<uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS" />
String[] projection = new String[] { Browser.BookmarkColumns.TITLE, Browser.BookmarkColumns.URL };
String selection = Browser.BookmarkColumns.BOOKMARK + " = 0"; // 排除书签
Cursor cursor = getContentResolver().query(Browser.BOOKMARKS_URI, projection, selection, null, null);
if (cursor != null && cursor.moveToFirst()) {
do {
String title = cursor.getString(cursor.getColumnIndex(Browser.BookmarkColumns.TITLE));
String url = cursor.getString(cursor.getColumnIndex(Browser.BookmarkColumns.URL));
// 处理浏览器历史记录数据
} while (cursor.moveToNext());
}
if (cursor != null) {
cursor.close();
}
推荐的腾讯云相关产品和产品介绍链接地址:
领取专属 10元无门槛券
手把手带您无忧上云