Android WebView untold stories
博客专区 > simpower 的博客 > 博客详情
Android WebView untold stories
simpower 发表于3年前
Android WebView untold stories
  • 发表于 3年前
  • 阅读 48
  • 收藏 2
  • 点赞 0
  • 评论 0


Without any doubts, Android SDK has a poor documentations. There are pitfalls and traps about APIs without any mentions in SDK documentations.

1. WebView.clearHistory()

When there is only one item in WebView’s internal back/forward list, clearHistory() won’t clear anything. When there are more than one items in back/forward list, clearHistory() will clear all the items except the top one, or the current one.

The next question you might ask is when WebView adds an item to its back/forward list when loading a URL. By listening WebChromeClient.onProgressChanged(), we can know this, when new progress is bigger than 10, the loading URL will be added to its back/forward list. So when new progress is bigger than 10, loading URL becomes current item and thus you can clear previous loaded URLs by calling clearHistory().

  • 打赏
  • 点赞
  • 收藏
  • 分享
共有 人打赏支持
粉丝 22
博文 366
码字总数 9341
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
* 支付类型