When I start an activty after receiving a GCM Message, it starts, next to the desired Activity, the MainActivity also. The problem is, I want to display the disired Activty (DialogActivity) as a Dialog-Box-Style Activity, so its background is transparent.
This is how I start the Activity:
@Override
protected void onMessage(Context arg0, Intent arg1) {
Log.d("GCM", "RECIEVED A MESSAGE");
generateNotification(arg0, arg1.getStringExtra("message"));
Intent i = new Intent();
i.setClass(this, DialogActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
}
This is the theme in the styles.xml
<style name="Theme.Transparent" parent="android:Theme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">false</item>
So the transparent Activity is laying on top of the MainActivity, which I want to avoid. It should show only the DialogActivity. Anyone knows help?
I already solved it. For anyone in future facing the problem:
Add FLAG_ACTIVITY_MULTIPLE_TASK Flag to the Intent
According to the Android Documentation