ホーム画面はマニフェストからトリガーできます。アクティビティを開始します。次のようにホーム画面にします。
<activity
android:name="com.example.HomeScreenActivity"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/title_activity_home_screen"
android:theme="@style/FullscreenTheme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
ミリ秒後に次の画面に切り替える場合は、次のようにアクティビティを作成します。
public class HomeScreenActivity extends Activity {
protected boolean _active = true;
protected int _splashTime = 3000; // time to display the splash screen in ms
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle("Your Activity Title");
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_home_screen);
// thread for displaying the HomeScreen
Thread homeTread = new Thread() {
@Override
public void run() {
try {
int waited = 0;
while(_active && (waited < _splashTime)) {
sleep(100);
if(_active) {
waited += 100;
}
}
} catch(InterruptedException e) {
// do nothing
} finally {
finish();
startActivity(new Intent("com.example.SecondViewActivity"));
}
}
};
homeTread.start();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
_active = false;
}
return true;
}
}