when I start my activity, I notice a slight delay. I click on the icon of my application, and the home screen remains on the screen for about 1-1.5 seconds before my activity is shown.
My activity onCreate method takes about 800 ms.
I also noticed that the installation android:screenOrientation="landscape"also adds a noticeable delay, even when I use test activity with an empty layout.
Is there any way to get rid of this delay or at least show a black screen while loading the user interface?
Edited: see code for test activity below. In my real life, there are a bunch of different downloads, including GUI elements and engine logic, sound, etc. The real problem is that the delay is visible even when using this small test activity.
Code for test activity:
public class TestActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
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);
}
}
XML format:
<?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>
hthms source
share