【问题标题】:Open Url in webView in android在android的webView中打开Url
【发布时间】:2012-11-07 11:42:09
【问题描述】:

如何在 webView 中打开这个 link。这是在浏览器上运行,但它不在 webView android 中运行。请给出解决方案。

【问题讨论】:

  • WebView webview = (WebView) findViewById(R.id.webview); webview.setWebViewClient(new WebViewClient() { public void onPageStarted(WebView view, String url, Bitmap favicon) { } }
  • 像上面一样检查
  • 当我使用其他都在 webview 中运行的 url 时
  • 听起来您的数据连接带宽较低。稍等片刻即可加载。
  • 把那个网址发给我..我会检查的

标签: java android webview


【解决方案1】:

活动:

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;

public class WebViewActivity extends Activity {

    private WebView webView;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.webview);

        webView = (WebView) findViewById(R.id.webView1);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.loadUrl("http://www.google.com");
    }
}

还有你的 XML:

<?xml version="1.0" encoding="utf-8"?>
<WebView  xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/webView1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
/>

【讨论】:

  • 我已经这样做了,其他 url 正在 webview 中运行,但我的 url 没有运行。请检查我的网址以在 webview 中打开。
  • 是的,你是对的。此链接有效。 uscis.gov/portal/site/uscis 但不是特定页面。当您通过手机浏览器访问 URL 时,它可以工作。我会调查更多。
  • 好的,我想我知道它可能是什么,但没有解决方案。您调用的页面被重定向到 https://。如果您尝试通过 hidemyass.com 之类的代理查看页面 egov.uscis.gov/cris/Dashboard.do,您会看到同样的问题。
  • 我刚找到这个,可能会有所帮助。 stackoverflow.com/questions/6121830/…
  • 总是乐于提供帮助。有人可以对此投票,以便用户可以看到有解决方案吗?谢谢。
【解决方案2】:

看看这个, 它对我有用......但我不知道它是否有任何副作用,但对我来说很好

       super.onCreate(savedInstanceState);        
       WebView theWebPage = new WebView(this);
       theWebPage.getSettings().setJavaScriptEnabled(true);
       theWebPage.getSettings().setPluginState(PluginState.ON); 
       setContentView(theWebPage);
       theWebPage.loadUrl("http://www.hkmytravel.com");

来源可以在 [http://www.androidpanna.com/functionality/webview-open-url-webpage-within-the-android-app-when-launch-android-development]

【讨论】:

  • @user8938 我刚刚启用了 Java Script 以用于其他需要 Java 脚本的网站。否则我们可能不需要这两行代码
  • 请告诉我,为什么 webview 不能打开像 google.com 这样的简单 url,为什么我们必须添加 https 或 http 作为 url 的前缀?
【解决方案3】:

测试以下内容:

<?xml version="1.0" encoding="utf-8"?>
<WebView  xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/webView1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
/>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-10-23
    • 1970-01-01
    • 2016-05-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-25
    相关资源
    最近更新 更多