我遇到了这个启动画面的问题。第一个应该持续3秒,然后进入第二次飞溅,但所有发生的事情是第一次打开然后没有其他任何想法发生?
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
public class Splash1 extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash1);
}
final Thread logoTimer = new Thread() {
public void run() {
try {
sleep(3000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
Intent splash2 = new Intent("com.zombieface.dubsnake.SPLASH2");
startActivity(splash2);
}
}
};
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
finish();
}
}
这是清单:
<activity
android:name=".Splash1"
android:configChanges="keyboard|keyboardHidden|orientation"
android:label="Dub Snake"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Splash2"
android:configChanges="keyboard|keyboardHidden|orientation"
android:label="Dub Snake"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="com.zombieface.dubsnake.SPLASH2" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
答案 0 :(得分:2)
如果那是您的所有代码,那么您忘记实际启动线程logoTimer
,以便您永远不会进入该循环并开始新活动。
来自onCreate()
来电:
logoTimer.start();