启动画面后Android应用程序强制关闭

时间:2014-02-14 04:29:15

标签: android android-intent manifest

我有一个启动画面,其计时器运行3秒钟。在3秒之后,它应该自动加载另一个名为Dashboard的活动。我在一个名为WelcomeSplash的启动画面后创建了一个我想要加载的新类。我将启动画面中的类从Dashboard更改为WelcomeSplash,app force关闭,logcat声明它有一个零点异常。以下是splash类和logcat snip的代码片段。

02-13 23:18:46.826: E/AndroidRuntime(2475): FATAL EXCEPTION: main
02-13 23:18:46.826: E/AndroidRuntime(2475): java.lang.RuntimeException: Unable to start   
activity ComponentInfo{com.magicbuddy.gamble/com.magicbuddy.gamble.welcomeSplash}:  
java.lang.NullPointerException
02-13 23:18:46.826: E/AndroidRuntime(2475):     at   
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)

以下是Splash代码的剪辑

    startActivity(new Intent(Splash.this, welcomeSplash.class));

当我将welcomeSPlash.class更改为Dashboard.class时,应用程序不会强制关闭。这是welcomeSplash活动,

public class welcomeSplash extends Activity implements OnClickListener {


Button btnskip;
Button btnplay;


@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.welcome);

  btnskip =(Button) findViewById(R.id.btnSkip);
  btnskip.setOnClickListener(this);
  btnplay =(Button) findViewById(R.id.btnOk);
  btnplay.setOnClickListener(this);


} 

public void onClick(View v) {
    switch (v.getId()) {
        case R.id.btnSkip:
            Intent a = new Intent(welcomeSplash.this, Dashboard.class);
            startActivity(a);
            break;
        case R.id.btnOk:
            Intent i = new Intent(welcomeSplash.this, Profile.class);
            startActivity(i);
            break;
    }
}
}

以下也复制了清单。

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.magicbuddy.gamble"
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="com.magicbuddy.gamble.Splash"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.magicbuddy.gamble.welcomeSplash"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="com.magicbuddy.gamble.Dashboard" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.magicbuddy.gamble.Dashboard"
        android:label="@string/app_name" >
    </activity>
    <activity
        android:name="com.magicbuddy.gamble.MainActivity"
        android:label="@string/app_name" >
    </activity>
    <activity
        android:name="com.magicbuddy.gamble.Player"
        android:label="@string/app_name" >
    </activity>
    <activity
        android:name="com.magicbuddy.gamble.Menu"
        android:label="@string/app_name" >
    </activity>
    <activity
        android:name="com.magicbuddy.gamble.Popup"
        android:label="@string/title_activity_popup" >
    </activity>
</application>

</manifest>

1 个答案:

答案 0 :(得分:0)

从您的清单中删除此代码

 <intent-filter>
        <action android:name="com.magicbuddy.gamble.Dashboard" />

        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>