我的webView活动显示为空白 [英] My webView activity shows blank
问题描述
我试图在我的Android活动上添加webview,但它的活动页面没有显示我给定的URL请帮助我。?
Am Trying to add webview on my android activity but its the activity page does not shows my given url please help me.?
DMS.java
package com.agte.vivo;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class Dms extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dms);
WebView myWebView = (WebView) findViewById(R.id.webView);
//myWebView.loadData("yourCode Html to load on the webView " , "text/html" , "utf-8");
myWebView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}});
myWebView.loadUrl("192.168.7.175/app/app.html");
}
}
活动DMS
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.agte.vivo.Dms">
<WebView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/webView"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true" />
</RelativeLayout>
没有显示错误,但我需要在Android应用程序中打开相同的网页如何修复此问题。?
there is no error shown but i need to to open the webpage same in android app how to fix this.?
推荐答案
从我所看到的代码中没有任何问题。您的问题是因为您正在尝试访问不可用的网址,因为它尚未公开到互联网。
From what I can see there is nothing wrong with the code. Your issue is because you are trying to access a URL which is not available, since it is not yet exposed to the internet.
仅仅是为了测试是否存在网址没有错,我建议将 192.168.7.175/app/app.html
更改为更可信的网站,例如 http:// www。 google.com
暂时。
Just for the sake of testing that there is nothing wrong in the url, I recommend changing 192.168.7.175/app/app.html
to a more plausable website such as http://www.google.com
for the time being.
您的下一步是找到一种方法将您的网站暴露在网络上,这样就可以了可从您的设备访问。如果安装了IIS,则可以将网站内容复制到 C:\inetpub\www
文件夹。这将向知道网址的任何人公开(在网络上提供)您的网站。您也可以使用本教程来帮助您。
Your next step is to find a way to expose your website to the web, so that it is accessible from your device. If you have IIS installed, you can copy your website content to the C:\inetpub\www
folder. This would expose (make it available on the web) your site to anyone knowing the url. You can also use this tutorial to help you.
这篇关于我的webView活动显示为空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!