Home » Android » android – Issues with Translucent Theme

android – Issues with Translucent Theme

Posted by: admin June 15, 2020 Leave a comment


I have an app that has two activities.
The first one is presented with a single button that opens the second one.

Here is the Manifiest definition for the first one:

        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />

Second activity:

    android:label="@string/title_activity_main_activity2" android:theme="@android:style/Theme.Translucent">

Here is how I launch the second activity (via OnClickListener for a button on the first activity):

public void startSecondActivityClick(View v) {
   Intent startActivity2 = new Intent(this, MainActivity2.class);

This works fine, however when I background the app by hitting home and the foreground the app. I’m noticing that the first activity is continually creating/destroying itself. I verified this by putting some code in the onDestory method to increment a static int:

private static int count = 0;

protected void onCreate(Bundle savedInstanceState) {


protected void onDestroy() {
    Log.i("MainActivity", String.format("Destroyed, %d", count));

I’ve also noticed that removing the translucent theme seems to fix this. My question is is there a way to translucent or something similar but also have it not restart? Also, I’m curious why this happens at all. I’m testing this on 4.0.1 ICS on a galaxy SIII.

How to&Answers:

Ok after some digging I was able to figure out why this is happening. Someone had turned on one of the developer options, “do not keep activities.”. After turning this off this stopped happening. I suspect this wouldn’t happen in production too often as most people probably don’t have that setting on. You can find this under settings -> “developer options” on most phones.