Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/191.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何隐藏PhoneGap Android SplashScreen?_Javascript_Android_Cordova - Fatal编程技术网

Javascript 如何隐藏PhoneGap Android SplashScreen?

Javascript 如何隐藏PhoneGap Android SplashScreen?,javascript,android,cordova,Javascript,Android,Cordova,我已经做了一个简单的应用程序来获取坐标,它工作得很好,但我在启动应用程序时遇到了一个问题,在启动index.html之前会出现一个空白屏幕。如何在启动应用程序时删除空白黑屏。我正在使用cordova-2.4.0.js 我的index.html是 <!DOCTYPE html> <html> <head> <title>Device Properties Example</title> <script type=

我已经做了一个简单的应用程序来获取坐标,它工作得很好,但我在启动应用程序时遇到了一个问题,在启动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>

在加载index.html时,我已经尝试删除该空白屏幕,但没有找到方法。我猜这是因为设备正在加载应用程序

你能做的是创建你自己的闪屏? 通过以下链接,您将了解如何创建自己的启动屏幕:


希望这能对您有所帮助。

是的,谢谢您的重播。但是我怎样才能将闪屏图像复制到我的Android项目的res/drawable目录中呢。我怎样才能得到这些图像?需要拍电影吗?还有其他方法吗?您只需将文档中的图像添加到res/drawable目录中即可。你可以用photoshop、gimp创建自己的闪屏。。。这是一个简单的图像,将其命名为splash.png并设置不同的大小,然后将它们复制到正确的目录中:(xhdpi):960x720(hdpi):640x480(mdpi):470x320(ldpi):426x320谢谢stephen。我会试试你的建议。
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;
    }

}