Can anyone guide me, Im trying to create a simple app that has splash and main menu activity.
I have implemented both of the activity and whenever I run the emulator I can see the splash pop up but it never goes to the main menu activity.
I tried to change the XML file in manifest as below:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.book" android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" />
<application android:icon="@drawable/ic_launcher"
android:label="@string/app_name" android:name=".activity.StartApp">
<activity
android:name=".activity.MainMenuApp"
android:label="@string/app_name">
</activity>
<activity android:name=".activity.SplashApp"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Can anyone suggest why the main menu did not show up?
Thanks.
Edit: SplashApp.java
import com.book.R;
public class SplashApp extends Activity {
private DBAdapter mDBAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
}
@Override
protected void onStart() {
super.onStart();
mDBAdapter = new DBAdapter(getApplicationContext());
try{
...
…. int sec = 1;
new Handler().postDelayed(new Runnable(){
public void run(){
Intent intent = new Intent(SplashApp.this, MainMenuApp.class);
startActivity(intent);
finish();
}
}, sec * 1000);
}catch (Exception e){
e.printStackTrace();
}
}
}
I found that the problem might be on my manifest file where it says:
package="com.book"
I am now able to load the splash activity but it won’t go to the main menu page?
If your main menu activity is actually an
Activity, it should be also noted in theandroidManifest.xmlfile (with or without intent filters):In case you are performing initialization tasks in the
SplashAppactivity, and the main functions of your applications reside in theMainActivity, you would find theDEFAULTintent filter useful though.edit1: remove the
android:nameattribute from theapplicationtag in the manifestedit2: use
SplashApp.this.finish()instead of simplyfinish(), because the this there refers to the Handler.SplashApp.java:
androidManifest.xml: