当我第一次启动我的应用程序时,它首先显示了可绘制的内容,然后在调用活动的onCreate方法时显示我的启动活动布局之前显示黑色屏幕。我已经为启动活动设置了主题。这是我的代码:
<style name="Theme.Holo.Beast.MainActivity" parent="@style/Theme.AppCompat.NoActionBar">
<item name="android:windowActionBar">false</item>
<item name="android:windowBackground">@drawable/bg_splash</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>
并在AndroidManifest.xml文件中:
<application
android:name=".BeastBikes"
android:allowBackup="true"
android:debuggable="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Holo.Beast"
tools:ignore="HardcodedDebugMode">
<activity
android:name=".main.MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@style/Theme.Holo.Beast.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="speedx" />
</intent-filter>
</activity>
<data android:scheme="speedx" />
</intent-filter>
</activity>
我的MainActivity代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d("TAG", "onCreate is called!");
hasBeenLaunched = true;
this.sp = getSharedPreferences(getPackageName(), 0);
new AdviertiseManager(MainActivity.this).adviertiseLoad();
this.handler.postDelayed(new Runnable() {
@Override
public void run() {
intentToNext();
}
}, 3000L);
}
@Override
protected void onDestroy() {
super.onDestroy();
if (null != handler) {
handler = null;
}
}
/**
* 跳转到下个页面
*/
private void intentToNext() {
if (!this.sp.getBoolean(TutorialActivity.PREF_HAS_SHOWN, false) && LocaleManager.isChineseTimeZone()) {
this.startActivity(new Intent(this, TutorialActivity.class));
this.finish();
} else {
this.gotoAuthenticationPageIfNeeded();
}
}