Android应用启动-闪屏(splash)
来源:互联网 发布:w7upnp nat端口失败 编辑:程序博客网 时间:2024/04/30 17:42
package com.example.splashdemo;import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.os.Handler;public class MainActivity extends Activity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);new Handler().postDelayed(new Runnable() {@Overridepublic void run() {// TODO Auto-generated method stubIntent intent = new Intent(MainActivity.this,SecondActivity.class);startActivity(intent);finish();}}, 2000);}@Overridepublic void onBackPressed() {//取消backpressed的响应}}
<activity android:name="com.example.splashdemo.MainActivity" android:label="@string/app_name" android:theme="@android:style/Theme.Black.NoTitleBar" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>