加载phonegap网站后,在android上隐藏启动屏幕 [英] Hide splash screen on android once phonegap site has loaded

查看:54
本文介绍了加载phonegap网站后,在android上隐藏启动屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站,该网站使用媒体查询在手机上看起来不错,我将其包装在phonegap中,因此也可以将其作为应用程序使用.我已经将super.loadUrl设置为我的网站,并且可以正常工作,我还拥有一个正常的启动画面,我想一直保持该画面,直到网站加载完毕.我遇到了此博客文章,按照说明进行操作.如果我将super.loadUrl设置为index.html(应用程序主页),但我的实际网站的loadUrl设置无效.

I have a website that uses media queries to look good on mobiles, I wrapped this up in phonegap so I can have it as an application too. I have set super.loadUrl to my site and this works, I also have a working splash screen that I want to keep up until the site has loaded. I came across this blog post and followed the instructions. It works if I am super.loadUrl to index.html (the app homepage) but not if I loadUrl of my actual site.

启动画面代码(主Java文件)

Splash screen code (main java file)

super.setIntegerProperty("splashscreen", R.drawable.splash);
super.loadUrl("My External Site Url", 20000);

Index.html代码(如果我将loadLrl加载到我的网站,则可以使用此代码)

Index.html code (this works if i loadUrl to it, but I want to loadUrl to my site)

document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
    navigator.splashscreen.hide();
}

但是,当我在外部html文件中使用上述代码(并包括cordova.js)时,它无法识别onDeviceReady,因此启动屏幕不会隐藏自身,并且我被困了20秒钟.

However, when I use the above code (and include cordova.js) in my external html file, it doesn't recognise onDeviceReady, so the splash screen doesn't hide itself, and I'm stuck waiting 20 seconds.

我错过了什么吗?我是否甚至可以从外部html文件(例如未在应用程序中内置的html文件)中使用onDeviceReady,还是应该可以正常工作,而我只是引用了cordova错误?

Am I missing something? Am I even allowed to use onDeviceReady from an external html file (e.g. one that is not build into the app) or should this work and I am just referencing cordova wrong?

推荐答案

原来,prototype.js的旧内容搞砸了.一旦我删除它,它就很棒了.

It turns out an old include of prototype.js was messing this up. Once I removed that it works awesomely.

对于未来的人,我得到的错误是:

For future people the errors I got were:

  • 应用程序对触摸没有反应,无法使用输入按钮和超链接.
  • 如果您按住输入,超链接等按钮,则会显示橙色的焦点框,但从不带我进入链接或激活输入按钮(光标或键盘)
  • 原型在任何时候都使我无法准备就绪,但是没有引发JS错误(IE不喜欢addEventListener)

这篇关于加载phonegap网站后,在android上隐藏启动屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆