Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I provide *immediate* confirmation of an app's execution when the main activity is transparent?
    primarykey
    data
    text
    <p>The main activity of my app is defined in the Android manifest file with the following attribute:</p> <p><code>android:theme="@style/Theme.Translucent.NoTitleBar"</code></p> <p>This makes the activity transparent, which in turn makes it possible to control the transparency of my app in code by manipulating the main View object (e.g., by invoking <code>setVisibility(View.INVISIBLE)</code> on the main view). This works fine.</p> <p>However, one undesirable consequence of this approach is that when the app is launched there is no visible response until my main View is displayed. Normally, the default black background of an app's main activity is immediately visible when an app is launched, which provides immediate confirmation that the app is starting to run in response to the user tapping its icon in the launcher. But with a transparent background, the user continues to look <em>through</em> the background at the display from which the app is being launched until the main view is displayed, and so it appears (during that interval) as if nothing has occurred.</p> <p>Even on a device with mediocre performance (e.g., the Motorola Droid) my view comes up in about one second, which is not too bad. However, on a really slow device (e.g., the G1) it can take almost four seconds. While this is not a disaster, I'd prefer an immediate response so that the user is not left wondering whether the app was in fact triggered.</p> <p>I have tried removing the transparent theme, which results in immediate confirmation via a black background, as usual. However, I've been unable to set the activity background to transparent in code once the app has been initialized. </p> <p>I've invoked <code>setTheme()</code> on the activity just prior to calling <code>setContentView()</code> for the first time, passing it a transparent theme, but this does not make the activity transparent.</p> <p>I've also tried this in <code>onCreate()</code> (again, just prior to calling <code>setContentView()</code>):</p> <pre><code>ColorDrawable transparentDrawable = new ColorDrawable(Color.TRANSPARENT); getWindow().setBackgroundDrawable(transparentDrawable); </code></pre> <p>This also appears to have no effect.</p> <p>I've also tried using a theme in my manifest that has <code>android:windowBackground</code> set to a drawable that is a mostly transparent PNG, but with some text (e.g., the app's name) superimposed on the transparent background that would provide a cue to the user that the app was loading. Unfortunately, the moment I use a drawable as part of the theme, the background fails to display at all until after the main view is initialized.</p> <p>All time-consuming initializations are already being done in a worker thread, so I'm not looking for advice on how to accomplish that. The view itself just takes a certain amount of time to display, and while it is fairly quick, nothing beats the instantaneous response of seeing the main activity's background as soon as the app is launched.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload