简体   繁体   English

科尔多瓦启动画面未显示

[英]Cordova splashscreen not showing

I've trying with several tutorials to have splascreen worked with at least default screen.png provided by cordova. 我正在尝试一些教程,以使splascreen至少与cordova提供的default screen.png一起使用。

i edited the xml in root of my appiclation path (ex: cordova/myapp) to add the 2 lines required to have splashcreen showed as follow: 我在我的应用路径(例如:cordova / myapp)的根目录中编辑了xml,以添加如下两行,以使splashcreen显示如下:

<?xml version='1.0' encoding='utf-8'?>
<widget id="fr.bacly.baclym" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>baclym</name>
    <description>
Application Mobile du Bacly    </description>
    <author email="philippe.ihuel@bacly.fr" href="http://cordova.io">
        Philippe Ihuel
    </author>
    <content src="index.html" />
    <preference name="Orientation" value="portrait" />
    <plugin name="cordova-plugin-whitelist" version="1" />
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <platform name="android">
    <!-- you can use any density that exists in the Android project -->
<!--         <splash src="res/res-land-hdpi/screen.png" density="land-hdpi"/>
        <splash src="res/res-land-ldpi/screen.png" density="land-ldpi"/>
        <splash src="res/res-land-mdpi/screen.png" density="land-mdpi"/>
        <splash src="res/res-land-xhdpi/screen.png" density="land-xhdpi"/>
        <splash src="res/res-port-hdpi/screen.png" density="port-hdpi"/>
        <splash src="res/res-port-ldpi/screen.png" density="port-ldpi"/>
        <splash src="res/res-port-mdpi/screen.png" density="port-mdpi"/>
        <splash src="res/res-port-xhdpi/screen.png" density="port-xhdpi"/> -->
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
    </platform>
        <preference name="SplashScreen" value="screen" />
        <preference name="SplashScreenDelay" value="30000" />    
</widget> 

I run on genymotion with a simulated S4 Android 4.4.2, but it doesnt show anything except a black screen for some times. 我在带有模拟S4 Android 4.4.2的genymotion上运行,但一段时间没有显示任何东西,但黑屏除外。

Any advice ? 有什么建议吗?

there is another way of doing that: 还有另一种方法:

This is your main Activity 这是你的主要活动

package com.example.abc;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
public class MainActivity extends Activity
 {

@Override

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
     this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.splash);

 Thread background = new Thread() {

        public void run() {

      try {       // Thread will sleep for 5 seconds

      sleep(5*1000); // After 5 seconds redirect to another intent
     Intent i=new Intent(getBaseContext(),Splash.class);

startActivity(i);

//Remove activity

       finish();
} 
 catch (Exception e) {}
}
};
// start thread
 background.start();
}

 @Override

 public void onDestroy() {


    super.onDestroy();
      }
     }

This is your Second Activity : 这是您的第二个活动:

 package com.example.abc;

 import org.apache.cordova.CordovaActivity;
 import android.os.Bundle;

 public class Splash extends CordovaActivity {

 @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        // Set by <content src="index.html" /> in config.xml
        loadUrl(file:///android_asset/www/index.html);
    }

  }

Make launcher mainActivity in manifest file. 在清单文件中将启动器设为mainActivity。

我终于设法按照这篇文章的答案工作了Cordova 3.4 Splashscreen无法正常工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM