2015-08-28 75 views
0

我已經嘗試了幾個教程,讓splascreen至少使用了由cordova提供的默認screen.png。科爾多瓦splashscreen不顯示

我編輯的XML在我appiclation路徑的根(例如:科爾多瓦/ MyApp的)添加到具有splashcreen所需的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="[email protected]" 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 genymotion運行4.4.2,但它不會顯示除黑屏以外的任何內容。

有什麼建議嗎?

+0

您已經添加了閃屏插件到您的項目答案下面的工作? –

+0

@mudasserajaz:是 – Nightf

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

    } 

使清單文件中的launcher mainActivity成爲可能。

+0

我正在開發n使用cordova進行部署,所以此解決方案可能無法滿足我的目的 – Nightf