我现在正在测试我的应用程序。但是,它始终在加载屏幕上崩溃。加载后,它将重定向到登录名或用户帐户(如果他们已经登录)。
但是,在构建应用程序时,我总是在android studios控制台日志中收到这些错误消息。W/cr_CrashFileManager: /data/user/0/chrisbeckett.********/cache/WebView/Crash Reports does not exist or is not a directory
// I've put the stars as I can't show the name of the application yet.
W/cr_AwContentsClient: Denied starting an intent without a user gesture, URI http://********.********.com/login
我当前的代码:
package chrisbeckett.**********;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Window;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
public class MainActivity extends AppCompatActivity {
private WebView mWebView;// Instance of WebChromeClient for handling all chrome functions.
private volatile WebChromeClient mWebChromeClient;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mWebView = (WebView) findViewById(R.id.activity_main_webview);
// Enable Javascript
WebSettings webSettings = mWebView.getSettings();
webSettings.setDomStorageEnabled(true);
webSettings.setJavaScriptEnabled(true);
webSettings.setCacheMode(WebSettings.LOAD_DEFAULT);
webSettings.setAppCacheEnabled(true);
webSettings.setAppCacheMaxSize(100 * 1000 * 1000);
mWebView.setWebChromeClient(new WebChromeClient());
mWebView.loadUrl("http://********.*********.com/loading");
}
/**
* Set the WebChromeClient.
* @param client An implementation of WebChromeClient.
*/
public void setWebChromeClient(WebChromeClient client) {
mWebChromeClient = client;
}
}
更多的信息:
在将代码置于App格式下进行测试时,在检查器中以移动模式查看它时,我的代码可在桌面上的所有Web浏览器上使用。
如果您需要更多信息,请告诉我。
最佳答案
试试下面的代码,这可能工作mWebView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return false;
}
});