Reputation: 3
I under stand the thousand of people saying "don't use a splash," I get it, but the app is not that big, I just want to know what I am doing wrong I think it is something with my Manifest but after my splash shows and when its supposed to go to main page, I get error "Sorry! The Application Grifball (process com.grifball.info) has stopped unexpectedly. Please try again.
Here is my Manifest.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.grifball.info"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="8" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity android:name="Splash">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.grifball.info.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
Here is my Splash's Java
package com.grifball.info;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
public class Splash extends Activity{
@Override
protected void onCreate(Bundle startup) {
// TODO Auto-generated method stub
super.onCreate(startup);
setContentView(R.layout.splash);
Thread timer = new Thread(){
public void run(){
try{
sleep(5000);
}catch(InterruptedException e){
e.printStackTrace();
}finally{
Intent openMainActivity = new Intent("com.grifball.info.MAINACTIVITY");
startActivity(openMainActivity);
}
}
};
timer.start();
}
}
Here is the XML
<?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:orientation="vertical"
android:background="@drawable/splashbg">
</LinearLayout>
Here is my Log Cat
04-03 02:39:20.527: D/AndroidRuntime(318): Shutting down VM
04-03 02:39:20.527: W/dalvikvm(318): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
04-03 02:39:20.537: E/AndroidRuntime(318): FATAL EXCEPTION: main
04-03 02:39:20.537: E/AndroidRuntime(318): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.grifball.info/com.grifball.info.MainActivity}: java.lang.RuntimeException: native typeface cannot be made
04-03 02:39:20.537: E/AndroidRuntime(318): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
04-03 02:39:20.537: E/AndroidRuntime(318): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-03 02:39:20.537: E/AndroidRuntime(318): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-03 02:39:20.537: E/AndroidRuntime(318): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-03 02:39:20.537: E/AndroidRuntime(318): at android.os.Handler.dispatchMessage(Handler.java:99)
04-03 02:39:20.537: E/AndroidRuntime(318): at android.os.Looper.loop(Looper.java:123)
04-03 02:39:20.537: E/AndroidRuntime(318): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-03 02:39:20.537: E/AndroidRuntime(318): at java.lang.reflect.Method.invokeNative(Native Method)
04-03 02:39:20.537: E/AndroidRuntime(318): at java.lang.reflect.Method.invoke(Method.java:521)
04-03 02:39:20.537: E/AndroidRuntime(318): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-03 02:39:20.537: E/AndroidRuntime(318): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-03 02:39:20.537: E/AndroidRuntime(318): at dalvik.system.NativeStart.main(Native Method)
04-03 02:39:20.537: E/AndroidRuntime(318): Caused by: java.lang.RuntimeException: native typeface cannot be made
04-03 02:39:20.537: E/AndroidRuntime(318): at android.graphics.Typeface.<init>(Typeface.java:147)
04-03 02:39:20.537: E/AndroidRuntime(318): at android.graphics.Typeface.createFromAsset(Typeface.java:121)
04-03 02:39:20.537: E/AndroidRuntime(318): at com.grifball.info.MainActivity.onCreate(MainActivity.java:27)
04-03 02:39:20.537: E/AndroidRuntime(318): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-03 02:39:20.537: E/AndroidRuntime(318): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-03 02:39:20.537: E/AndroidRuntime(318): ... 11 more
Upvotes: 0
Views: 3742
Reputation: 1477
Give the below code a try, it should work.
public class Splash extends Activity {
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setTheme(android.R.style.Theme_Light_NoTitleBar);
setContentView(R.layout.splash);
Handler handler = new Handler();
handler.postDelayed(new Runnable(){
public void run(){
finish();
Intent intent = new Intent(Splash.this, MainActivity.class);
Splash.this.startActivity(intent);
}
}, 2000);
}
}
Upvotes: 0
Reputation: 18151
You have to make the following changes
<activity android:name=".Splash">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
</activity>
finally{
Intent openMainActivity = new Intent(Splash.this, MainActivity.class);
startActivity(openMainActivity);
Upvotes: 0
Reputation: 12656
In the "AndroidManifest.xml", you should change this:
<action android:name="com.grifball.info.MAINACTIVITY" />
To This:
<action android:name="android.intent.action.MAINACTIVITY" />
And, in "Splash.java", you should change:
Intent openMainActivity = new Intent("com.grifball.info.MAINACTIVITY");
To this:
Intent openMainActivity = new Intent(Splash.this, MainActivity.class);
Upvotes: 3