앱을 실행하면 SplashScreen이 화면에서 몇 초 동안 깜박이고 3 초 동안 완전히 사라집니다. 3 초를 마친 후 MainActivity가 시작됩니다. 질문 : 화면이 꺼지지 않고 스플래시 화면을 표시하는 방법은 무엇입니까?스플래시 화면이 안드로이드에 표시되지 않음
public class SplashScreen extends Activity {
private static int SPLASH_TIME_OUT = 3000;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash_screen);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
startActivity(new Intent(SplashScreen.this, MainActivity.class));
}
}, SPLASH_TIME_OUT);
SplashScreen.this.finish();
}
@Override
public void onBackPressed() {
SplashScreen.this.finish();
super.onBackPressed();
}}
매니페스트 파일
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity android:name="com.simbotix.guardianonthego.SplashScreen" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.simbotix.guardianonthego.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
해야하는 이유는, 같은 내가 설명해 주시겠습니까? {SplashScreen.this.finish(); // Remove this} – Shiva
누를 때 활동이 자동으로 끝나고 onDestroy 메소드가 호출됩니다. – Sunny
SplashScreen.java에 onDestroy 메소드를 포함시켜야합니까? – Shiva