我的项目的一部分我想使用闪屏。代码一切正常,但不幸的是,启动画面在开始时没有加载。我的清单文件是
<activity
android:label="@string/app_name"
android:name="com.example.GamePlay.SplashScreen"
android:configChanges="orientation|keyboardHidden"
android:theme="@android:style/Theme.Wallpaper.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"> </activity>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<activity
android:name="com.example.GamePlay.Game"
android:configChanges="orientation|keyboardHidden"
android:theme="@android:style/Theme.Wallpaper.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"
android:label="@string/app_name"></activity>
闪屏.java
public class SplashScreen extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash_screen);
Thread welcomeThread = new Thread() {
int wait = 0;
@Override
public void run() {
try {
super.run();
while (wait < 2000) {
sleep(100);
wait += 100;}
} catch (Exception e) {
System.out.println("SplashScreen()"+e.toString());
} finally {
System.out.println("Final statment for run()");
} } };
welcomeThread.start();
new AsyncTask<Void, Void, Void>(){
@Override
protected Void doInBackground(Void... params) {
LayoutInflater inflater = (LayoutInflater) SplashScreen.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
Game.cachedView = inflater.inflate(R.layout.activity_game, null, false);
return null;
}
@Override
protected void onPostExecute(Void aVoid) {
finish();
Intent intent = new Intent(getBaseContext(), Game.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(intent);
}
}.execute();
} }
请帮我解决这个问题。