phonegap-splashscreen

本文详细介绍了如何自定义启动页面,并利用延迟加载技术优化应用性能。通过使用HTML、JavaScript和Cordova框架,实现了一个简洁高效的启动流程,同时展示了如何在应用启动时进行页面加载与隐藏操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

其实就是自定义一个启动页面,不顾完全可以不用这么做,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);
}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值