I'm new to Android Java programming.
I've created a simple chat app. Things are going well, but I've hit a small snag. I've set launchMode="singleTop" in my manifest's application tag, and overrided the back button, so now the chat app remains running (in the background) when the user presses the back or home button. I've also created some notifications that pop up in that status bar when a new chat appears (with intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP) set), and when the user clicks the notification it brings the already running chat app to the front. That's all working fine; the problem arises after I bring up the app from the status bar notification, then click back or home, then choose to open the app from the applications menu or a shortcut on the launcher, and thats when it opens up a second instance of the app.
Is that clear?
If the app isn't running and I choose to run it from app menu, it runs (doesn't display any chats because it hasn't received any). I receive a chat and see it on screen in the app, I press back button, I go back and open app through app menu, it runs and has the chat messages from before. Good. Now I press back (so app is in background, but still running), I receive a chat, it pops up a status bar notification, I click it, it opens up the app and shows chat messages from before. Good. Now I click back (so app is running in background). I then open the app through the app menu (like I did the first and second time), but this time it doesn't show the previous chat messages, and if I receive a chat, it makes 2 notification sounds, so I know it has started a new instance of the app.
Any idea what's wrong?
Thanks.