Cordova s​​plashscreen未显示

时间:2015-08-28 12:29:31

标签: android cordova

我正在尝试使用几个教程来使splascreen至少使用cordova提供的default screen.png。

我在我的appiclation路径的根目录中编辑了xml(例如:cordova / myapp),添加了如下所示的2行所示的闪屏:

<?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> 

我使用模拟的S4 Android 4.4.2在genymotion上运行,但除了黑屏以外它没有显示任何东西。

有什么建议吗?

2 个答案:

答案 0 :(得分:0)

还有另一种方法:

  

这是您的主要活动

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();
      }
     }
  

这是你的第二项活动:

 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);
    }

  }
  

在清单文件中创建启动器mainActivity。

答案 1 :(得分:0)

我终于设法按照这篇文章的答案开始工作了 Cordova 3.4 Splashscreen not working