【发布时间】:2019-12-12 12:59:03
【问题描述】:
我正在为我的本地网络制作一个 webview 应用程序。我有两个静态 IP。我想做的就是在第一个失败的情况下加载第二个。 (因为其中一个始终在运行)。
我正在做的是在onRecievedError()函数中检查它并更改URL值,然后像这样再次调用onCreate()。
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl){
Toast.makeText(getApplicationContext(), "Failed loading app!", Toast.LENGTH_SHORT).show();
url1="http://192.168.43.XXX"; //here XXX is used just to hide my IP from public
onCreate(new Bundle());
}
onCreate() 方法必须呈现新 URL,但我的应用程序在此调用时自行关闭。为什么会这样?
请帮忙,因为我是初学者。
【问题讨论】:
标签: android android-studio webview