【问题标题】:Load first page on splashscreen using phonegap on android在android上使用phonegap在启动画面上加载第一页
【发布时间】:2012-02-17 12:16:07
【问题描述】:

您好,我正在将 phonegap 与 Jquery mobile 结合使用。我正在尝试立即获取主页,同时向用户显示启动画面。

在 Android 的 PhoneGap 中我正在使用这个

super.setIntegerProperty("splashscreen", R.drawable.splash);
super.loadUrl("file:///android_asset/www/index.html", 2000);

虽然这会加载启动画面,但也会延迟 index.html 的加载。是否可以立即开始获取它?另外,如果不使用 phonegap,有没有人使用 JQM 而不是 phonegap 做到这一点?

更新:在加载速度较慢的首页(执行 json 请求)使用它后,它看起来有点像启动屏幕显示了更长的时间,所以这似乎是默认行为

【问题讨论】:

  • 我不认为立即加载它是可能的:(
  • 嗯,真可惜。我会考虑用 JQM 来做这件事。也许他们也有一种简单的方法来加载启动画面,但我希望有人已经这样做了
  • 嗨,我正在为同样的问题苦苦挣扎……尝试在预取 phonegap + JQM 多页 index.html 时显示 android 的原生构建启动画面。你找到解决办法了吗?任何帮助/经验都会被应用。我想摆脱我的android-splash之后出现的“3秒黑屏”。

标签: android jquery-mobile cordova splash-screen


【解决方案1】:

如给定的here,您可以在加载完所有资产并加载 DOM 元素后终止启动画面。

类似这样的: 爪哇:

super.setIntegerProperty("splashscreen",R.drawable.splashscreen);
super.loadUrl("file:///android_asset/www/index.html", 2000);

在您的 HTML、javascript 部分:

function onDeviceReady() 
            {
                cordova.exec(null, null, "SplashScreen", "hide", []);
                window.MacAddress = new MacAddress();
                window.MacAddress.getMacAddress(function(result){
                    database._mac_address = result.mac;
                }, function(){
                    database._mac_address = '01:02:03:04:05:06';
                });  
            }

【讨论】:

    【解决方案2】:

    我已经实施了更好的解决方案。 您可以设置自定义启动画面并在页面加载后通过 JS 调用将其隐藏

    https://github.com/inetstd/phonegap-android-custom-splashscreen/wiki

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-31
      • 1970-01-01
      • 2011-12-30
      • 2020-02-26
      • 1970-01-01
      • 2012-12-29
      相关资源
      最近更新 更多