I want to create a activity with transparent background that I can start by clicking on a Notification.
I created the notification and the activity with no problem, but now, I want to open this particular TransparentActivity independently i.e. without showing the other activities on the background.
I tried to put some flags on the intent:
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
and on the AndroidManifest file, on my TransparentActivity tag, I put:
<activity
android:name=".TransparentActivity"
android:launchMode="singleTask"
android:theme="@style/Theme.Transparent">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
It works as expected, but now I have two icons for my app, which is something I don't want.
Is there a way to make it work?
Easiest way to do this is to change the taskAffinity
for this Activity
in the manifest. Add:
android:taskAffinity=""
to the <activity> declaration for this one
Activity`.
This one Activity
will then be launched into a new task, and not into the task that runs the rest of your application.