- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
重现问题的步骤:
创建一个内部有 WebView 的 fragment 。
在构建历史记录的 WebView 中深入浏览几个站点。
尝试使用 webview.canGoBack() 函数。
观察它总是返回 false。
这是一个新行为,因为 WebView 之前确实返回了 true。
似乎新版本的 WebView 已经破坏了这个功能。
这是我的代码:
class MyWebViewClient extends WebViewClient {
// Loads all hyperlinks in the existing WebView
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
// Protection against getActivity() returning null object reference
if (!isAdded()) return true;
// Allow WebView to load url
Uri uri = Uri.parse(url);
// Google Maps
if (url.contains("maps.google")) {
Intent mapIntent = new Intent(Intent.ACTION_VIEW, uri);
mapIntent.setPackage("com.google.android.apps.maps");
if (mapIntent.resolveActivity(getActivity().getPackageManager()) != null) {
startActivity(mapIntent);
}
return true;
}
// Telephone
else if (url.contains("tel:")) {
String phoneNumber = url.substring(4);
Utils.dialPhone(getActivity(), phoneNumber);
return true;
}
// Redirect
return false;
}
}
这是我使用 goBack API 的地方:
public boolean canWebViewGoBack() {
if (mWebView != null) {
if (mWebView.canGoBack()) {
return true;
}
}
return false;
}
public void webViewGoBack() {
if (mWebView != null) {
if (mWebView.canGoBack()) {
mWebView.goBack();
}
}
}
最佳答案
在这里link
谈谈问题和可能的解决方案
关于java - Android WebView canGoBack 总是返回 false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47830836/
我像这样将这个网站嵌入到我的应用程序中: NSString *url = [NSString stringWithFormat:@"https://mobile.twitter.com/search?
如果 canGoBack,我将在 webview 中显示返回按钮是真的。 它工作正常,但对于一个特定的网页,即使没有返回页面,webview 说 cangoback 为 true 而 cangobac
我有一个 Android 应用程序,我试图在标题中显示一些自定义后退/前进按钮,让用户知道他们可以后退或前进。我的想法是切换不透明度并设置是否启用它们(如果用户可以在 WebView 中后退或前进)。
最近,我所有基于 WebView 的应用程序都开始出现后退按钮问题。某些 Android 组件的更新看起来有问题,请帮助解决这个问题或一些替代解决方案? webView.canGoBack() 总是返
我正在遵循( Building Web Apps in WebView )教程,但我遇到了(导航网页历史记录)问题,我在我的设备上运行它并单击链接,但当我单击后退按钮时,应用程序关闭: 这是我的 Ac
我希望 webview 在按下后退按钮时显示上一页我正在使用 .canGoBack 来完成此操作,但“.canGoBack”和“.GoBack”带有红线下划线,声明 ==== “无法从静态上下文引用非
我有一个正在加载社交媒体页面的 WebView。我已经覆盖了返回按钮以调用 WebView 上的 goBack 方法,直到 canGoBack() 返回 false。然后调用 super.onBack
我对 Android Web View 有疑问。当我在扩展 WebViewClient 的类中覆盖函数 shouldOverrideUrlLoading 时,WebView.canGoBack() 总
在调用NavigationService.GoBack()之前我们需要检查NavigationService.CanGoBack是否为真,但是NavigationService.CanGoBack在什
我正在加载这样的请求 [resultsWebView loadRequest:searchRequest];然后我这样做 - (void) webViewDidFinishLoad:(UIWebVie
重现问题的步骤: 创建一个内部有 WebView 的 fragment 。 在构建历史记录的 WebView 中深入浏览几个站点。 尝试使用 webview.canGoBack() 函数。 观察它总是
我的应用程序中有一个 WebView,它显示从网页下载的 HTML 数据。为什么我加载 HTML 而不是单独加载 URL?嗯,为了允许离线搜索,我下载了 HTML 数据并将其存储在 SQL 数据库中。
我正在尝试使用历史记录作为退出应用程序的检查。主页按钮将页面重新加载到 google.com,但即使在我调用 .clearHistory() 之后仍然保留页面历史记录。 这是菜单处理/选择的代码: @
我正在使用动态 tabhost 创建应用程序,每个选项卡都有使用以下教程的动态 webview, http://www.pocketmagic.net/?p=1132 以上是作为自定义控件创建的(无法
我试图在 Ionic 应用程序中放置一个后退按钮,并在它位于根目录时隐藏后退按钮,该根不是固定的,可以根据流程进行更改。我在这里找到了以下代码: ... constructor( privat
我正在尝试将数据直接加载到 UIWebView: [webView loadData:data MIMEType:@"text/html" textEncodingName:@"utf-8"
这是我的功能: checkStack(){ let canGoBack = this.navCtrl.canGoBack() console.log('canGoBack: ',can
简单的概念,但它不起作用。我的 UIWebView 中有两个按钮,一个后退按钮和一个前进按钮。后退按钮调用 [self.webView goBack] 和前进按钮 [self.webView goFo
我是 Xamarin.Forms 的新手,所以如果我使用的词不正确,请原谅。为了创建一个简单的移动浏览器,我创建了一个名为“WebBrowser”的解决方案;目前我正在处理通用文件 MainPage.
我有一个 Android webview,我希望它通过 Android 后退按钮返回。如果以前的站点是 https://www.aaa.com/index.php 和 https://www.aaa.
我是一名优秀的程序员,十分优秀!