0

I have an Activity that runs at start up that handles global configuration and determines the correct Activity to launch based on the current application state. Since the Activity does not require any UI I am using Theme.NoDisplay, doing my work in onStart, starting the next activity and calling finish().

<activity android:name=".StartUpActivity" android:theme="@android:style/Theme.NoDisplay>

protected void onStart() {
    super.onStart();

    doConfiguration();
    startServices();
    startNextActivity();
    finish();
}

This was working fine until I needed to add an asynchronous service call. Since the service call returned after onResume() I started getting this error:

An activity without a UI must call finish() before onResume() completes
Justin Fiedler
  • 6,478
  • 3
  • 21
  • 25

1 Answers1

6

To fix this error I needed to change the Activity's theme to Theme.Translucent.NoTitleBar

<activity android:name=".StartUpActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar">
Justin Fiedler
  • 6,478
  • 3
  • 21
  • 25
  • For more, see [this blog post](https://commonsware.com/blog/2015/11/02/psa-android-6p0-theme.nodisplay-regression.html). – CommonsWare Nov 30 '15 at 19:29