when I start my Activity, I notice a short delay. I click on my app icon and the home screen stays on the screen for about 1-1.5 sec before my activity is shown.
My activity's onCreate method takes about 800ms to finish.
I've also noticed that setting android:screenOrientation="landscape"
also adds a noticeable delay, even when I use a test Activity with an empty layout.
Is there a way to get rid of this delay, or at least show a black screen while the UI is loading?
Edited: see code for test activity below. In my real activity there is a bunch of other loading including GUI elements and engine logic, sound, etc. The real issue is that the delay is visible even using this small test activity.
Code for test activity:
public class TestActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set full screen mode and disable
// the keyguard (lockscreen)
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
| WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
| WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setContentView(R.layout.main);
}
}
Layout XML:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="true" >
</FrameLayout>
Manifest:
<activity
android:name=".TestActivity"
android:configChanges="orientation|keyboardHidden"
android:label="@string/app_name"
android:screenOrientation="landscape"
android:windowSoftInputMode="stateAlwaysHidden|adjustPan" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>