I'm beginning to develop and I tried following a set of tutorials on Youtube. I got really confused after trying to follow tutorial 1.8.
What happens is I launch the application (using the emulator), then it opens the application. It then goes to the splash.xml screen, which is just a background, for five seconds. Then, it's suppose to go back to MainActivity.java screen, which is the main screen. Unfortunately, after showing five seconds of the splash screen, it tells me the application has stopped.
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.eduardopelaez.minecraftforums"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<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>
</application>
</manifest>
splash.xml (which is shown for 5 seconds after opening application):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/minecraft_wallpaperrepeating"
android:orientation="vertical" >
</LinearLayout>
MainActivity.java (which is suppose to come after splash.xml, but this is where it crashes):
package com.eduardopelaez.minecraftforums;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle TravisIsAwesome) {
super.onCreate(TravisIsAwesome);
setContentView(R.layout.splash);
Thread logoTimer = new Thread() {
public void run() {
try {
sleep(5000);
Intent menuIntent = new Intent(
"com.eduardopelaez.minecraftforums.MAINACTIVITY");
startActivity(menuIntent);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally {
finish();
}
}
};
logoTimer.start();
}
@Override
public boolean onCreateOptionsMenu(android.view.Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}