我的項目的一部分我想使用啓動畫面。代碼一切正常,但不幸的是啓動畫面不會在啓動時加載。 我的清單文件是啓動畫面不加載
<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>
SplashScreen.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();
} }
請幫我解決這個問題。
將意圖過濾器**置於** splash splash清單元素中。 – Luksprog
我會認真地推薦你學習更多關於Android的知識。看看你發佈的代碼和XML,整個事情從一開始就註定要失敗。 – Squonk