gpt4 book ai didi

android - 如何清除 android marshmallow 中的浏览历史记录

转载 作者:行者123 更新时间:2023-11-29 20:16:51 25 4
gpt4 key购买 nike

我正在清除 android 中的浏览器历史记录。直到 android 5.1.1 即; Lollipop 以下语法工作正常。

Browser.clearHistory(mContextUtility.getContentResolver());

但是,对于 android 6 即;棉花糖它不起作用。那么我该如何解决这个问题,有没有其他方法可以清除浏览器历史记录?

最佳答案

查看 Android 源代码,它看起来对您来说没有前途。请注意,clearHistory 方法不再执行任何操作,因此 canClearHistory 始终返回 false

/**
* Returns whether there is any history to clear.
*
* @param cr The ContentResolver used to access the database.
* @return boolean True if the history can be cleared.
* @removed
*/
public static final boolean canClearHistory(ContentResolver cr) {
return false;
}

/**
* Delete all entries from the bookmarks/history table which are
* not bookmarks. Also set all visited bookmarks to unvisited.
*
* @param cr The ContentResolver used to access the database.
* @removed
*/
public static final void clearHistory(ContentResolver cr) {
}

以下是 5.1.1 r1 中的相同方法,当它们实际起作用时:

    public static final boolean More ...canClearHistory(ContentResolver cr) {
Cursor cursor = null;
boolean ret = false;
try {
cursor = cr.query(History.CONTENT_URI,
new String [] { History._ID, History.VISITS },
null, null, null);
ret = cursor.getCount() > 0;
} catch (IllegalStateException e) {
Log.e(LOGTAG, "canClearHistory", e);
} finally {
if (cursor != null) cursor.close();
}
return ret;
}

Delete all entries from the bookmarks/history table which are not bookmarks. Also set all visited bookmarks to unvisited. Requires android.Manifest.permission Parameters: cr The ContentResolver used to access the database.

public static final void More ...clearHistory(ContentResolver cr) {
deleteHistoryWhere(cr, null);
}

关于android - 如何清除 android marshmallow 中的浏览历史记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33689672/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com