简体   繁体   English

Android应用在设备上加载白屏

[英]Android app loading white screen on device

I've debugged my app on my PC and it works fine. 我在我的电脑上调试了我的应用程序,它工作正常。 When I go into my phone and tablet instead of it loading the WebView like it should it simply loads a white screen, I guess failing to load the web site. 当我进入我的手机和平板电脑而不是它加载WebView它应该只是加载一个白色的屏幕,我想无法加载网站。 I'm not sure where to begin debugging since my debug mode and virtual device works fine. 我不知道从哪里开始调试,因为我的调试模式和虚拟设备工作正常。 Any suggestions? 有什么建议么?

A couple of suggestions based on these issues: 基于这些问题的一些建议:

  1. Make sure you have permissions on your devices in the Manifest file: 确保您在清单文件中拥有对设备的权限:
  2. Make sure your devices actually have internet access 确保您的设备实际上可以访问互联网
  3. Possibly enable javascript (ie mWebView.getSettings().setJavaScriptEnabled(true)) 可能启用javascript(即mWebView.getSettings()。setJavaScriptEnabled(true))
  4. Try loading a different URL (ie http://google.com ) to see if that loads 尝试加载其他网址(例如http://google.com )以查看是否加载了该网址
  5. Try changing the background color to see if your content is loading, but you can't see it (ie mWebView.setBackgroundColor(Color.parseColor("#000000"));) 尝试更改背景颜色以查看您的内容是否正在加载,但您无法看到它(即mWebView.setBackgroundColor(Color.parseColor(“#000000”));)

The fact that it's working locally but not on device suggests either connection issues or permissions in my opinion. 它本地工作但不在设备上的事实表明我认为连接问题或权限。 The other option is that the html you're loading is corrupt and the browser on your device(s) are breaking on rendering them. 另一个选择是你加载的html已损坏,你设备上的浏览器在渲染它们时会中断。

Android WebView shows a blank page Android WebView显示空白页面

Does your WebView require JavaScript? 您的WebView是否需要JavaScript? If so you'll need to enable it. 如果是这样,您将需要启用它。

webView.getSettings().setJavaScriptEnabled(true);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM