如何隐藏PhoneGap Android SplashScreen
How to hide PhoneGap Android SplashScreen?
我已经做了一个简单的应用程序来获取坐标,它运行得很好,但我在启动应用程序时遇到了一个问题,在启动index.html之前会出现一个空白黑屏。我如何在启动应用程序时删除那个空白黑屏。我使用的是cordova-2.4.0.js
我的index.html是
<!DOCTYPE html>
<html>
<head>
<title>Device Properties Example</title>
<script type="text/javascript" charset="utf-8" src="cordova-2.4.0.js"></script>
<script type="text/javascript" charset="utf-8">
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
// cordova.exec(null, null, "SplashScreen", "hide", []);
navigator.splashscreen.hide();
}
</script>
<style>
h3 {
left: 0;
line-height: 50px;
margin-top: -100px;
position: absolute;
text-align: center;
top: 60%;
width: 100%;
}
body
{
background-color:#D7EBFF;
}
header
{
background-color:#C3E1FF;
}
</style>
<script type="text/javascript">
function showLocation(position)
{
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
document.getElementById("demo").innerHTML="Latitude : " + latitude + "</br> Longitude: " + longitude ;
//alert("Latitude : " + latitude + " Longitude: " + longitude);
}
function errorHandler(err)
{
if(err.code == 1)
{
alert("Error: Access is denied!");
}
else if( err.code == 2)
{
alert("Error: Position is unavailable!");
}
}
function getLocation()
{
var watchID = null;
if(navigator.geolocation)
{
var options = { timeout: 5000, enableHighAccuracy: true };
watchID = navigator.geolocation.watchPosition(showLocation, errorHandler, options);
}
else
{
alert("Sorry, does not support geolocation!");
}
}
</script>
</head>
<body onload="getLocation();">
<header>
<center>
<h2>Gps Coordinates </h2>
</center>
</header>
<h3>
<p id="demo">Searching for GPS..</p>
</h3>
</body>
</html>
我的MainActivity.java类是
public class MainActivity extends DroidGap {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/WWW/index.html");
//setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
我已经尝试在加载index.html时删除那个空白屏幕,但我不知道怎么做。我想是因为设备正在加载应用程序。
你能做的是创建自己的启动屏幕吗?通过以下链接,您将了解如何创建自己的启动屏幕:http://docs.phonegap.com/en/2.2.0/cordova_splashscreen_splashscreen.md.html
希望能对你有所帮助。
相关文章:
- onLoad function phonegap android
- GCM推送通知,如果应用程序在手机中关闭(Phonegap Android)
- Phonegap-Android 4.4-html5音频长度错误(javascript和媒体插件)
- phonegap Android中的pdf查看器
- 科尔多瓦 PhoneGap Android 回调与数据
- Phonegap (Android) - 数据库更改版本不起作用
- 访问设备'Phonegap Android中的本地日历
- 在phonegap android中上传多个文件时,使用jquery ui显示进度条
- 正在将数据URL(base64)保存到PhoneGap(android)上的文件中
- 如何在phonegap(android)中设置facebook好友生日提醒
- 如何隐藏PhoneGap Android SplashScreen
- 读取phonegap android应用程序中的本地文件
- 如何使我的phonegap android应用程序崩溃
- 阻止 YouTube API 在 PhoneGap Android 上全屏显示
- Phonegap Android Geolocation watch位置超时
- PhoneGap Android后退按钮需要按两次
- Phonegap android 向其他应用程序用户发送通知
- “在线”事件 Phonegap Android 未能在 StateChange 上开火
- Phonegap Android项目适用于模拟器,而不是实际的手机
- Phonegap Android 在输入焦点 Javascript 上显示键盘