0

我理解成千上万的人说“不要使用飞溅”,我明白了,但应用程序并没有那么大,我只是想知道我做错了什么我认为这是我的清单的问题,但在我之后启动画面,当它应该进入主页时,我收到错误“对不起!应用程序 Grifball(进程 com.grifball.info)已意外停止。请重试。

这是我的清单。

<?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>

这是我的 Splash 的 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();
}

}

这是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>

这是我的原木猫

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
4

3 回答 3

3

在“AndroidManifest.xml”中,你应该改变这个:

<action android:name="com.grifball.info.MAINACTIVITY" />

对此:

<action android:name="android.intent.action.MAINACTIVITY" />

而且,在“Splash.java”中,您应该更改:

Intent openMainActivity = new Intent("com.grifball.info.MAINACTIVITY");

对此:

Intent openMainActivity = new Intent(Splash.this, MainActivity.class);
于 2013-04-03T02:10:14.660 回答
0

您必须进行以下更改

<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);
于 2013-04-03T02:11:08.340 回答
0

试试下面的代码,它应该可以工作。

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

}
于 2013-04-03T02:16:07.587 回答