Bug : Theme.Translucent & FLAG_ACTIVITY_REORDER_TO_FRONT Bug : Theme.Translucent & FLAG_ACTIVITY_REORDER_TO_FRONT android android

Bug : Theme.Translucent & FLAG_ACTIVITY_REORDER_TO_FRONT


If we do not set the theme from AndroidManifest.xml, activity block and set the theme before setContentView, in onCreate method in the first translucent activity, the problem is solved, below is the code:

public class TranslucentActivityDemoActivity extends Activity {    @Override    public void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);
      this.setTheme(R.style.myTheme);
        setContentView(R.layout.main);    }


As a workaround not an answer

I have done this:

public class OverlayActivity extends Activity {   @Override   protected void onNewIntent(Intent intent) {       super.onNewIntent(intent);       // Restart self when attempting to be brought to front       Intent restartIntent = new Intent(this, OverlayActivity.class);       startActivity(restartIntent);       finish();   }   @Override   protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_overlay);   } }

if anyone can give me an answer they win the brucey bonus!


The launchMode should be singleTask in the <activity> tag of your activity in the manifest file.

From Documentation :

singleTask - If, when starting the activity, there is already a task running that starts with this activity, then instead of starting a new instance the current task is brought to the front. The existing instance will receive a call to Activity.onNewIntent() with the new Intent that is being started, and with the Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT flag set. This is a superset of the singleTop mode, where if there is already an instance of the activity being started at the top of the stack, it will receive the Intent as described there (without the FLAG_ACTIVITY_BROUGHT_TO_FRONT flag set).

Update

As a better workaround you can try invalidating the whole window in onNewIntent() or in onResume..

@Overrideprotected void onNewIntent(Intent intent) {   super.onNewIntent(intent);   getWindow().getDecorView().invalidate();}