0

I am developing my first app now and I see that whenever I click on a new activity it opens up and everything is fine. I can also go back to the main activity and then open a different and it all works.

However once I open the task switcher, all the previous activities show up. They all show up as seperate apps and if I click on one of them that is not the main activity I cannot go back the to the main activity its like its very own up with just that activity.

This is very strange. Does this have to do with how I implement the onDestory method? Because to be quite frank I never used it.

Please help me!

Thank you!

Edon Freiner
  • 338
  • 2
  • 17
  • 1
    How do you launch your activities? Do you have any non-default values for launchMode, documentLaunchMode or taskAffinity? See here: https://developer.android.com/guide/topics/manifest/activity-element.html#lmode – Nonos Mar 30 '18 at 00:42
  • Thanks, I didnt quite understand the differences between al 4 but I call the new activity using 'new Intent(MainActivity.this, className);' for whatever activity is being called – Edon Freiner Mar 30 '18 at 00:46
  • 1
    How does your manifest look like? I think we need to see more code here with details on how you start the activities (do you add any flags .. etc) – Nonos Mar 30 '18 at 00:49
  • 1
    And they're quite confusing, I think this could help shed some lights: https://developer.android.com/guide/components/activities/tasks-and-back-stack.html – Nonos Mar 30 '18 at 00:50
  • hey, this is what I found in the manifest file android:launchMode="singleInstance" I hope this helps, if you need more code, please let me know. Thanks! – Edon Freiner Mar 30 '18 at 01:01
  • 1
    That's exactly the reason, if you leave it to the default then you would allow your activities to start in the same task – Nonos Mar 30 '18 at 01:04
  • Ok thanks, and what would the default be? or should I just erase it completely? Also, I think the reason i put that in the first place was because when you clicked the activity twice, it would open the activity twice. Which was an issue – Edon Freiner Mar 30 '18 at 01:06

0 Answers0