4

I have 3 activities ( say A, B, C were A-is the Launch activity). When I press home button when at activity C, app goes into background. After that, I took my app through all apps list menu. At that time, my launch activity is showing (activity A). When I press back button, It goes to previous activity (C). I want to retain in the same activity (C) while coming back from background. When I run application through Eclipse, It works fine. But when I send Apk file through mail and run it in device, It fails (previous problem occurs ). I tried with

android:launchMode="standard"

AND

android:alwaysRetainTaskState="true"

in my launch activity (Login activity or A). Any body please help me, Thanks in advance.

Jithu
  • 1,478
  • 1
  • 13
  • 21
  • 1
    Yup.. I too had the same issue..... had a work around.. yet not fixed.... – DGN May 21 '13 at 12:17
  • Check if you are doing startActivity for A anywhere in the code. If from "C", you had to go back to "A", then, ideally you should "finish" C so that it goes back to parent activity "A" – Wand Maker May 21 '13 at 12:17
  • 1
    @Wand Actually I want to directly go to activity C when coming back from background, Not to launcher activity A. – Jithu May 21 '13 at 12:24
  • 1
    In my case, When I take the app from recent list(apps in background), It's working fine. – Jithu May 21 '13 at 12:26
  • Typically, that should work fine. only time I had run into this kind of issue was when we were using FragmentActivity and when the view gets restored from background, the default initialization of fragment would take it to a fragment that is it initialized with. – Wand Maker May 21 '13 at 12:34
  • When i use backbutton from activity A(when came back from background), It navigates to activity C. Actually, my activity A(Login activity is finish() just after logged in on normal case.) – Jithu May 21 '13 at 12:40
  • What you describe is the standard Android behaviour. Maybe you overrode a default setting; maybe try to prune AndroidManifest to the bare minimum, or post it here? – etienne May 23 '13 at 16:35
  • Try this: Install the APK. Don't open the app from the installer. Just close the installer after you've installed the app. Then open app from the list of available apps. See if your problem has gone away. If so, you are seeing this nasty Android bug. See my answer here: http://stackoverflow.com/a/16447508/769265 – David Wasser Jun 05 '13 at 13:10

1 Answers1

0

Follow following steps to insure that you are following the right practice: 1. Make sure you are using finish(); on the Activity A or B if you want to finish it and dont if you want the back button functionality. 2. Try Implementing onpause() and onresume() even if you are not going to perform any functionality in them. Use super() for them there. 3. Also, in android when you start an activity by clicking on the icon instead of resuming it from already running activities, it exhibits a different behaviour.

AhmedRed
  • 67
  • 4