其实就是自定义一个启动页面,不顾完全可以不用这么做,MainActivity就可以充当启动页面来做,这个是官方的例子就顺便学习一下。同时这里也有延迟加载的例子。
index.html
<!DOCTYPE html>
<html>
<head>
<title>Splashscreen Example</title>
<script type="text/javascript" charset="utf-8" src="cordova-2.0.0.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for Cordova to load
//
document.addEventListener("deviceready", onDeviceReady, false);
// Cordova is ready
//
function onDeviceReady() {
//navigator.splashscreen.show();
navigator.splashscreen.hide();
}
</script>
</head>
<body>
<h1>Example</h1>
</body>
</html>
MainActivity.java
package com.fanfq.phonegap.splashscreen;
import org.apache.cordova.DroidGap;
import android.os.Bundle;
public class MainActivity extends DroidGap {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// The first line 'super.setIntegerProperty' sets the image to be
// displayed as the splashscreen. If you have named your image anything
// other than splash.png you will have to modify this line. The second
// line is the normal 'super.loadUrl' line but it has a second parameter
// which is the timeout value for the splash screen. In this example the
// splash screen will display for 10 seconds. If you want to dismiss the
// splash screen once you get the "deviceready" event you should call
// the navigator.splashscreen.hide() method.
super.setIntegerProperty("splashscreen", R.drawable.splash);
super.loadUrl("file:///android_asset/www/index.html", 10000);
}
}
分享到:
相关推荐
devextreme-mobile-splashscreen 带有自定义启动画面的 DevExtreme 移动应用程序 DevExtreme Mobile(又名 PhoneJS - 我认为?)很棒! 我已经在 Cordova(又名 PhoneGap - 我想?我很困惑)包装的几个项目中使用它...
目前我有:com-ionic-keyboard,cordova-plugin-console,cordova-plugin-device,cordova-plugin-splashscreen,cordova-plugin-vibration,cordova-plugin-whitelist) 类型:“ adb start-server”(您应该看到已...
在PhoneGap应用中,启动画面(Splash Screen)是一个很常见的元素。通常情况下,我们希望应用启动时首先显示一个启动画面,然后才跳转到主界面。启动画面可以通过以下步骤进行设置: 1. 将`splash.PNG`文件拷贝到`...
第四行的`setIntegerProperty("splashscreen", R.drawable.splash)`是用来设置启动屏幕的图片资源,当应用启动时,这个图片会显示一段时间。 接着,我们检查网络连接状态: ```java ConnectivityManager ...
#hooks for Cordova/PhoneGap/Ionic 用于cordova 3.x+ 项目的实用程序挂钩。 ##添加插件(030_add_plugins.js) 在准备/构建/运行项目之前自动安装插件。... 在 splashscreen.json 中添加配置需要:包创作者