Transparent Activity opening independently












1















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?










share|improve this question

























  • Add: Intent.FLAG_ACTIVITY_CLEAR_TASK

    – Shaishav
    Aug 20 '16 at 14:25











  • It did not work. Should I do something else other than adding this new flag?

    – LeonardoSibela
    Aug 20 '16 at 14:28











  • To understand you situation, can you post screenshot of two icons ?

    – nshmura
    Aug 20 '16 at 15:59











  • I don't have a screenshot right now (I can send it later) but Android will create one icon for every single activity with the intent filter "LAUNCHER" when installing the app.

    – LeonardoSibela
    Aug 20 '16 at 17:24











  • You should remove the <intent-filter> for your TransparentActivity. You don't need that. Android creates an application icon for each and every Activity that has an <intent-filter> with ACTION=MAIN and CATEGORY=LAUNCHER.

    – David Wasser
    Aug 23 '16 at 7:08
















1















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?










share|improve this question

























  • Add: Intent.FLAG_ACTIVITY_CLEAR_TASK

    – Shaishav
    Aug 20 '16 at 14:25











  • It did not work. Should I do something else other than adding this new flag?

    – LeonardoSibela
    Aug 20 '16 at 14:28











  • To understand you situation, can you post screenshot of two icons ?

    – nshmura
    Aug 20 '16 at 15:59











  • I don't have a screenshot right now (I can send it later) but Android will create one icon for every single activity with the intent filter "LAUNCHER" when installing the app.

    – LeonardoSibela
    Aug 20 '16 at 17:24











  • You should remove the <intent-filter> for your TransparentActivity. You don't need that. Android creates an application icon for each and every Activity that has an <intent-filter> with ACTION=MAIN and CATEGORY=LAUNCHER.

    – David Wasser
    Aug 23 '16 at 7:08














1












1








1


0






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?










share|improve this question
















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?







android android-intent android-activity android-pendingintent start-activity






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 2 at 2:13









Cœur

19k9112154




19k9112154










asked Aug 20 '16 at 14:23









LeonardoSibelaLeonardoSibela

462818




462818













  • Add: Intent.FLAG_ACTIVITY_CLEAR_TASK

    – Shaishav
    Aug 20 '16 at 14:25











  • It did not work. Should I do something else other than adding this new flag?

    – LeonardoSibela
    Aug 20 '16 at 14:28











  • To understand you situation, can you post screenshot of two icons ?

    – nshmura
    Aug 20 '16 at 15:59











  • I don't have a screenshot right now (I can send it later) but Android will create one icon for every single activity with the intent filter "LAUNCHER" when installing the app.

    – LeonardoSibela
    Aug 20 '16 at 17:24











  • You should remove the <intent-filter> for your TransparentActivity. You don't need that. Android creates an application icon for each and every Activity that has an <intent-filter> with ACTION=MAIN and CATEGORY=LAUNCHER.

    – David Wasser
    Aug 23 '16 at 7:08



















  • Add: Intent.FLAG_ACTIVITY_CLEAR_TASK

    – Shaishav
    Aug 20 '16 at 14:25











  • It did not work. Should I do something else other than adding this new flag?

    – LeonardoSibela
    Aug 20 '16 at 14:28











  • To understand you situation, can you post screenshot of two icons ?

    – nshmura
    Aug 20 '16 at 15:59











  • I don't have a screenshot right now (I can send it later) but Android will create one icon for every single activity with the intent filter "LAUNCHER" when installing the app.

    – LeonardoSibela
    Aug 20 '16 at 17:24











  • You should remove the <intent-filter> for your TransparentActivity. You don't need that. Android creates an application icon for each and every Activity that has an <intent-filter> with ACTION=MAIN and CATEGORY=LAUNCHER.

    – David Wasser
    Aug 23 '16 at 7:08

















Add: Intent.FLAG_ACTIVITY_CLEAR_TASK

– Shaishav
Aug 20 '16 at 14:25





Add: Intent.FLAG_ACTIVITY_CLEAR_TASK

– Shaishav
Aug 20 '16 at 14:25













It did not work. Should I do something else other than adding this new flag?

– LeonardoSibela
Aug 20 '16 at 14:28





It did not work. Should I do something else other than adding this new flag?

– LeonardoSibela
Aug 20 '16 at 14:28













To understand you situation, can you post screenshot of two icons ?

– nshmura
Aug 20 '16 at 15:59





To understand you situation, can you post screenshot of two icons ?

– nshmura
Aug 20 '16 at 15:59













I don't have a screenshot right now (I can send it later) but Android will create one icon for every single activity with the intent filter "LAUNCHER" when installing the app.

– LeonardoSibela
Aug 20 '16 at 17:24





I don't have a screenshot right now (I can send it later) but Android will create one icon for every single activity with the intent filter "LAUNCHER" when installing the app.

– LeonardoSibela
Aug 20 '16 at 17:24













You should remove the <intent-filter> for your TransparentActivity. You don't need that. Android creates an application icon for each and every Activity that has an <intent-filter> with ACTION=MAIN and CATEGORY=LAUNCHER.

– David Wasser
Aug 23 '16 at 7:08





You should remove the <intent-filter> for your TransparentActivity. You don't need that. Android creates an application icon for each and every Activity that has an <intent-filter> with ACTION=MAIN and CATEGORY=LAUNCHER.

– David Wasser
Aug 23 '16 at 7:08












1 Answer
1






active

oldest

votes


















1














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 oneActivity`.



This one Activity will then be launched into a new task, and not into the task that runs the rest of your application.






share|improve this answer


























  • I was using task affinity, but "singleTask" instead of "singleInstance". I read the tasks and back-stack documentation, and I was sure "singleTask" was the one I was looking for. Using "singleInstance" worked for me, thanks :D

    – LeonardoSibela
    Aug 22 '16 at 20:06






  • 1





    I don't know why you edited my answer and added the word "singleInstance" to the taskAffinity declaration. This has nothing to do with launchMode and that edit certainly confused the matter. You set the taskAffiinity to an empty string and that means that the Activity has no affinity for any other activities, so it can run in any task. In reality it makes no difference that string you use, but using the string "singleInstance" could surely confuse people. I reedited my answer.

    – David Wasser
    Aug 23 '16 at 7:06








  • 1





    Looking at your original post, you are not using taskAffinity, you are using launchMode="singleTask".

    – David Wasser
    Aug 23 '16 at 7:11






  • 1





    I'm sorry about editing your question. I confused launchMode with taskAffinity and I'm very glad you changed it back :) Once more, thank you very, very much for your help.

    – LeonardoSibela
    Aug 23 '16 at 14:47











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f39055164%2ftransparent-activity-opening-independently%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














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 oneActivity`.



This one Activity will then be launched into a new task, and not into the task that runs the rest of your application.






share|improve this answer


























  • I was using task affinity, but "singleTask" instead of "singleInstance". I read the tasks and back-stack documentation, and I was sure "singleTask" was the one I was looking for. Using "singleInstance" worked for me, thanks :D

    – LeonardoSibela
    Aug 22 '16 at 20:06






  • 1





    I don't know why you edited my answer and added the word "singleInstance" to the taskAffinity declaration. This has nothing to do with launchMode and that edit certainly confused the matter. You set the taskAffiinity to an empty string and that means that the Activity has no affinity for any other activities, so it can run in any task. In reality it makes no difference that string you use, but using the string "singleInstance" could surely confuse people. I reedited my answer.

    – David Wasser
    Aug 23 '16 at 7:06








  • 1





    Looking at your original post, you are not using taskAffinity, you are using launchMode="singleTask".

    – David Wasser
    Aug 23 '16 at 7:11






  • 1





    I'm sorry about editing your question. I confused launchMode with taskAffinity and I'm very glad you changed it back :) Once more, thank you very, very much for your help.

    – LeonardoSibela
    Aug 23 '16 at 14:47
















1














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 oneActivity`.



This one Activity will then be launched into a new task, and not into the task that runs the rest of your application.






share|improve this answer


























  • I was using task affinity, but "singleTask" instead of "singleInstance". I read the tasks and back-stack documentation, and I was sure "singleTask" was the one I was looking for. Using "singleInstance" worked for me, thanks :D

    – LeonardoSibela
    Aug 22 '16 at 20:06






  • 1





    I don't know why you edited my answer and added the word "singleInstance" to the taskAffinity declaration. This has nothing to do with launchMode and that edit certainly confused the matter. You set the taskAffiinity to an empty string and that means that the Activity has no affinity for any other activities, so it can run in any task. In reality it makes no difference that string you use, but using the string "singleInstance" could surely confuse people. I reedited my answer.

    – David Wasser
    Aug 23 '16 at 7:06








  • 1





    Looking at your original post, you are not using taskAffinity, you are using launchMode="singleTask".

    – David Wasser
    Aug 23 '16 at 7:11






  • 1





    I'm sorry about editing your question. I confused launchMode with taskAffinity and I'm very glad you changed it back :) Once more, thank you very, very much for your help.

    – LeonardoSibela
    Aug 23 '16 at 14:47














1












1








1







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 oneActivity`.



This one Activity will then be launched into a new task, and not into the task that runs the rest of your application.






share|improve this answer















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 oneActivity`.



This one Activity will then be launched into a new task, and not into the task that runs the rest of your application.







share|improve this answer














share|improve this answer



share|improve this answer








edited Aug 23 '16 at 7:03

























answered Aug 22 '16 at 12:03









David WasserDavid Wasser

69.9k10143202




69.9k10143202













  • I was using task affinity, but "singleTask" instead of "singleInstance". I read the tasks and back-stack documentation, and I was sure "singleTask" was the one I was looking for. Using "singleInstance" worked for me, thanks :D

    – LeonardoSibela
    Aug 22 '16 at 20:06






  • 1





    I don't know why you edited my answer and added the word "singleInstance" to the taskAffinity declaration. This has nothing to do with launchMode and that edit certainly confused the matter. You set the taskAffiinity to an empty string and that means that the Activity has no affinity for any other activities, so it can run in any task. In reality it makes no difference that string you use, but using the string "singleInstance" could surely confuse people. I reedited my answer.

    – David Wasser
    Aug 23 '16 at 7:06








  • 1





    Looking at your original post, you are not using taskAffinity, you are using launchMode="singleTask".

    – David Wasser
    Aug 23 '16 at 7:11






  • 1





    I'm sorry about editing your question. I confused launchMode with taskAffinity and I'm very glad you changed it back :) Once more, thank you very, very much for your help.

    – LeonardoSibela
    Aug 23 '16 at 14:47



















  • I was using task affinity, but "singleTask" instead of "singleInstance". I read the tasks and back-stack documentation, and I was sure "singleTask" was the one I was looking for. Using "singleInstance" worked for me, thanks :D

    – LeonardoSibela
    Aug 22 '16 at 20:06






  • 1





    I don't know why you edited my answer and added the word "singleInstance" to the taskAffinity declaration. This has nothing to do with launchMode and that edit certainly confused the matter. You set the taskAffiinity to an empty string and that means that the Activity has no affinity for any other activities, so it can run in any task. In reality it makes no difference that string you use, but using the string "singleInstance" could surely confuse people. I reedited my answer.

    – David Wasser
    Aug 23 '16 at 7:06








  • 1





    Looking at your original post, you are not using taskAffinity, you are using launchMode="singleTask".

    – David Wasser
    Aug 23 '16 at 7:11






  • 1





    I'm sorry about editing your question. I confused launchMode with taskAffinity and I'm very glad you changed it back :) Once more, thank you very, very much for your help.

    – LeonardoSibela
    Aug 23 '16 at 14:47

















I was using task affinity, but "singleTask" instead of "singleInstance". I read the tasks and back-stack documentation, and I was sure "singleTask" was the one I was looking for. Using "singleInstance" worked for me, thanks :D

– LeonardoSibela
Aug 22 '16 at 20:06





I was using task affinity, but "singleTask" instead of "singleInstance". I read the tasks and back-stack documentation, and I was sure "singleTask" was the one I was looking for. Using "singleInstance" worked for me, thanks :D

– LeonardoSibela
Aug 22 '16 at 20:06




1




1





I don't know why you edited my answer and added the word "singleInstance" to the taskAffinity declaration. This has nothing to do with launchMode and that edit certainly confused the matter. You set the taskAffiinity to an empty string and that means that the Activity has no affinity for any other activities, so it can run in any task. In reality it makes no difference that string you use, but using the string "singleInstance" could surely confuse people. I reedited my answer.

– David Wasser
Aug 23 '16 at 7:06







I don't know why you edited my answer and added the word "singleInstance" to the taskAffinity declaration. This has nothing to do with launchMode and that edit certainly confused the matter. You set the taskAffiinity to an empty string and that means that the Activity has no affinity for any other activities, so it can run in any task. In reality it makes no difference that string you use, but using the string "singleInstance" could surely confuse people. I reedited my answer.

– David Wasser
Aug 23 '16 at 7:06






1




1





Looking at your original post, you are not using taskAffinity, you are using launchMode="singleTask".

– David Wasser
Aug 23 '16 at 7:11





Looking at your original post, you are not using taskAffinity, you are using launchMode="singleTask".

– David Wasser
Aug 23 '16 at 7:11




1




1





I'm sorry about editing your question. I confused launchMode with taskAffinity and I'm very glad you changed it back :) Once more, thank you very, very much for your help.

– LeonardoSibela
Aug 23 '16 at 14:47





I'm sorry about editing your question. I confused launchMode with taskAffinity and I'm very glad you changed it back :) Once more, thank you very, very much for your help.

– LeonardoSibela
Aug 23 '16 at 14:47




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f39055164%2ftransparent-activity-opening-independently%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

MongoDB - Not Authorized To Execute Command

How to fix TextFormField cause rebuild widget in Flutter

in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith