2
A
回答
3
对于我这个代码工作
private void clearHistoryChrome() {
ContentResolver cr = getContentResolver();
if (canClearHistory(cr)) {
deleteHistoryWhere(cr, null);
}
}
private void deleteHistoryWhere(ContentResolver cr, String whereClause) {
String CONTENT_URI = "content://com.android.chrome.browser/history";
Uri URI = Uri.parse(CONTENT_URI);
Cursor cursor = null;
try {
cursor = cr.query(URI, new String[]{"url"}, whereClause,
null, null);
if (cursor != null) {
if (cursor.moveToFirst()) {
final WebIconDatabase iconDb = WebIconDatabase.getInstance();
do {
// Delete favicons
// TODO don't release if the URL is bookmarked
iconDb.releaseIconForPageUrl(cursor.getString(0));
} while (cursor.moveToNext());
cr.delete(URI, whereClause, null);
}
}
} catch (IllegalStateException e) {
Log.i("DEBUG_", "deleteHistoryWhere IllegalStateException: " + e.getMessage());
return;
} finally {
if (cursor != null) cursor.close();
}
Log.i("DEBUG_", "deleteHistoryWhere: GOOD");
}
public boolean canClearHistory(ContentResolver cr) {
String CONTENT_URI = "content://com.android.chrome.browser/history";
Uri URI = Uri.parse(CONTENT_URI);
String _ID = "_id";
String VISITS = "visits";
Cursor cursor = null;
boolean ret = false;
try {
cursor = cr.query(URI,
new String[]{_ID, VISITS},
null, null, null);
if (cursor != null) {
ret = cursor.getCount() > 0;
}
} catch (IllegalStateException e) {
Log.i("DEBUG_", "canClearHistory IllegalStateException: " + e.getMessage());
} finally {
if (cursor != null) cursor.close();
}
Log.i("DEBUG_", "canClearHistory: " + ret);
return ret;
}
我认为这将有助于你
相关问题
- 1. 以编程方式查找Chrome浏览器历史记录
- 2. 清除浏览器历史记录
- 3. 清除Android浏览器历史记录
- 4. 清除CefGlue浏览器历史记录
- 5. 以编程方式访问浏览器历史记录
- 6. 以编程方式访问谷歌浏览器历史记录
- 7. 编程方式清除浏览器缓存/历史
- 8. 以编程方式清除Microsoft IME输入历史记录
- 9. 以编程方式清除Android地图历史记录
- 10. 清除web应用程序的浏览器历史记录
- 11. 删除浏览器历史记录
- 12. 是否可以使用JavaScript以编程方式清除客户端上的浏览器历史记录?
- 13. 如何以编程方式使用C#清除Adobe阅读器历史记录
- 14. 使用c#清除Asp.net MVC3中的浏览器历史记录?
- 15. 在窗口电话7中清除历史记录浏览器?
- 16. 清除浏览器缓存,历史记录和Cookie
- 17. 使用jQuery清除浏览器历史记录/ javascript
- 18. 通过Asp.net-C清除浏览器历史记录#
- 19. Chrome浏览器是否有Bookmark ContentProvider以获取浏览器历史记录
- 20. 如何在本地机器上以编程方式访问Google Chrome浏览器历史记录
- 21. 用javascript清除浏览器历史记录(或防止URL被记录)
- 22. 如何以编程方式检索Safari的完整浏览历史记录?
- 23. Microsoft Edge删除历史记录和Cookie以编程方式
- 24. 的Android编程方式操作浏览器历史记录的单元测试
- 25. 浏览器历史记录或CSS
- 26. Phonegap Cordova浏览器历史记录
- 27. 浏览器历史记录管理
- 28. 读取浏览器历史记录
- 29. smartgwt浏览器历史记录
- 30. Ajax +浏览器历史记录
注意'Browser'在API级别完全消除23 – CommonsWare
@CommonsWare你知道如果有反正与Chrome浏览器交互? – SPatrickApps
Android SDK本身没有任何内容。无论Chrome团队是否为其Android应用程序记录了任何类型的API,我都不能说。 – CommonsWare