你好我在使用splashcreen后遇到了我的主要活动,应用程序崩溃了。启动画面显示很好,但我的应用程序会崩溃,我想我可能已经在我的androidmanifest中做了错误,但我不确定。
AndroidManifest.xml
chmod
SplashScreen.java
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.test.testing">
<application>
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<!-- Splash screen -->
<activity
android:name="com.example.test.testing.ui.SplashScreen"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Black.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Main activity -->
<activity
android:name="com.example.test.testing.ui.ListActivity"
android:label="@string/app_name" >
</activity>
<!-- 2nd activity -->
<activity android:name=".ui.DetailActivity" />
</application>
</manifest>
activity_splash.xml
package com.example.test.testing.ui;
import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import com.example.test.testing.R;
public class SplashScreen extends Activity {
// Splash screen timer
private static int SPLASH_TIME_OUT = 3000;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
new Handler().postDelayed(new Runnable() {
/*
* Showing splash screen with a timer. This will be useful when you
* want to show case your app logo / company
*/
@Override
public void run() {
// This method will be executed once the timer is over
// Start your app main activity
Intent i = new Intent(SplashScreen.this, ListActivity.class);
startActivity(i);
// close this activity
finish();
}
}, SPLASH_TIME_OUT);
}
}
答案 0 :(得分:0)
您好,您必须使用以下内容替换您的应用程序代码: -
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<!-- Splash screen -->
<activity
android:name="com.example.test.testing.ui.SplashScreen"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Black.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Main activity -->
<activity
android:name="com.example.test.testing.ui.ListActivity"
android:label="@string/app_name" >
</activity>
<!-- 2nd activity -->
<activity android:name=".ui.DetailActivity" />
</application>