I already looked up similar posts on SO. I have added splash.java class, splash_layout.xml file,
i had 2 app icons appearing on desktop emulator and splash was there, but 2 icons is not good I suspect it is about manifest, what do I put in there as android.MAIN, android.DEFAULT?
This is my android manifest.xml file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.kaban.it_ebooksinfomobile" >
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@drawable/logo"
android:label="@string/app_name"
android:theme="@style/Theme.Book">
<something must be here for splash screen before MainActivity...>
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
This is splash java file:
package com.example.kaban.it_ebooksinfomobile;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
public class SplashScreen extends Activity {
private final int SPLASH_DISPLAY_LENGTH = 1000;
private static boolean splashLoaded = false;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
if(!splashLoaded){
setContentView(R.layout.splashscreen);
splashLoaded = true ;
/* New Handler to start the Menu-Activity
* and close this Splash-Screen after some seconds.*/
new Handler().postDelayed(new Runnable(){
@Override
public void run() {
/* Create an Intent that will start the Menu-Activity. */
startActivity(new Intent(SplashScreen.this, MainActivity.class));
finish();
}
}, SPLASH_DISPLAY_LENGTH);
}
else {
Intent goToMainActivity = new Intent(SplashScreen.this, MainActivity.class);
goToMainActivity.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(goToMainActivity);
finish();
}
}
}
But it still does not load my splash! it used to load, but with 2 app icons on virtual emulator desktop, which is stupid. I don't think it s right to make my .SplashActivity my launcher, i already did this:
<activity
android:name=".HomeScreen"
android:label="@string/app_name" >>
</activity>
<activity
android:name=".Splash"
android:label="@string/title_activity_splash_screen" >>
<intent-filter>
<action android:name="android.intent.action.MAIN" />>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
< /activity>