Undefined
Undefined

Reputation: 764

On back button pressed same activity appears when app is launched

I have an app which displays 2 fragments once launched which I can then swipe right and left to change them.

The problem I am facing is that once the app is launched the first time(after being killed) and if I were to press the back button, activity swipes back and the same activity appears, but once I press back button again, then the app exits as supposed to do. If I were to reopen the app which is running in the background and if I press back button again, app will exit as normal.

So the problem is that when the first time app is launched and if I press the back button the activity will swipe to the right and the same activity appears.

Can anyone tell me where the problem could be as I have no idea which code to include for the refference as I have no clue who is causing this problem..

Upvotes: 0

Views: 418

Answers (1)

Undefined
Undefined

Reputation: 764

After spending hours trying to find the solution I finally found that placing

android:launchMode="singleTask"

inside manifest under the activity which seemed to cause the problem solved this issue

Upvotes: 1

Related Questions