This question concerns memory in Android.
My method:
I have two activites, A and B. From A, I launch B like this:
Intent i =
If you have 5 instances of activity B, then you are not managing the activity stack correctly. I find the best way to check it is with the CLI command:
adb shell dumpsys meminfo 'your apps package name'
I had a similar problem in a two activity project when I switched between them. Every time I switched I got a new instance on the stack as revealed by the above command. I then set the flags for the launched activities to FLAG_ACTIVITY_REORDER_TO_FRONT with code like:
Intent i = new Intent("com.you.yourActivityB");
i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(i);
Once I'd done this, then the adb shell command did not show more instances of my two activities when I switched between them