[android-developers] Re: savedInstanceState always null
What you are experiencing is a known bug (at least known by me for over a year now). Check out my answer here http://stackoverflow.com/questions/3042420/home-key-press-behaviour/4782423#4782423 I've also filed an issue a couple of months ago. The idea is that in some situations, after you press HOME and come back to the app, a new copy of the initial activity is created, instead of resuming the old one. Check out the details in the link provided. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: savedInstanceState always null
Android page says..You newer can handle Home button..it is easy to understant.. if you can handle home button you can newer close program..You always start intent..That is bad for users.. For that you cant handle home button press... 2011/9/22, kaciula catalin.moro...@gmail.com: What you are experiencing is a known bug (at least known by me for over a year now). Check out my answer here http://stackoverflow.com/questions/3042420/home-key-press-behaviour/4782423#4782423 I've also filed an issue a couple of months ago. The idea is that in some situations, after you press HOME and come back to the app, a new copy of the initial activity is created, instead of resuming the old one. Check out the details in the link provided. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: savedInstanceState always null
I think I misunderstood when onRestoreInstanceState is called so ignore that part. But the problem still remains, the bundle is always null even though it is saved. I have logging showing me onSaveInstanceState is called. On Sep 20, 12:11 pm, GregAZ ggur...@gmail.com wrote: savedInstanceState is always null. For some reason this just started happening. onSaveInstanceState is being called but here's what's happening: 1. Launch app by pressing app icon 2. Hit home button (I've verified onSaveInstanceState is called) 3. Launch app by pressing app icon 4. Attempt to read savedInstanceState in onCreate but it's null Example of my onSaveInstanceState: protected void onSaveInstanceState(Bundle outState) { // TODO Auto-generated method stub outState.putString(uploadUrl, uploadUrl); super.onSaveInstanceState(outState); } What would cause this to be null? public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) // always null { uploadUrl = savedInstanceState.getString(uploadUrl); } } I just added the following override and it's never called (I have logging in it): @Override protected void onRestoreInstanceState(Bundle savedInstanceState) { } I'm just storing short term values so I don't want to use preferences. The problem is if a new activity opens those values are lost and I need them when the user goes back to the original activity. This was working. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: savedInstanceState always null
I'm finally getting some where. I need to read up on the life cycle cuz I'm getting myself screwed up. Here's what's happening: Debug mode: 1. Tap app icon to open app, onCreate is called 2. Hit home button, state is saved 3. Tap app icon to open app, it resumes, onCreate is not called In debug mode I'm happy, works great. Now I export the signed and zip aligned app and repeat these steps: 1. Tap app icon to open app, onCreate is called 2. Hit home button, state is saved 3. Tap app icon to open app, onCreate is called again #3 is calling onCreate again. If instead of doing step 3 I hold home down and switch to the app it just resumes, onCreate isn't called again. I thought I had instance problems but it seems my problem is onCreate is called when it shouldn't be which is starting my app all over again. Bundle is null, my variables are reset, etc. On Sep 20, 12:21 pm, GregAZ ggur...@gmail.com wrote: I think I misunderstood when onRestoreInstanceState is called so ignore that part. But the problem still remains, the bundle is always null even though it is saved. I have logging showing me onSaveInstanceState is called. On Sep 20, 12:11 pm, GregAZ ggur...@gmail.com wrote: savedInstanceState is always null. For some reason this just started happening. onSaveInstanceState is being called but here's what's happening: 1. Launch app by pressing app icon 2. Hit home button (I've verified onSaveInstanceState is called) 3. Launch app by pressing app icon 4. Attempt to read savedInstanceState in onCreate but it's null Example of my onSaveInstanceState: protected void onSaveInstanceState(Bundle outState) { // TODO Auto-generated method stub outState.putString(uploadUrl, uploadUrl); super.onSaveInstanceState(outState); } What would cause this to be null? public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) // always null { uploadUrl = savedInstanceState.getString(uploadUrl); } } I just added the following override and it's never called (I have logging in it): @Override protected void onRestoreInstanceState(Bundle savedInstanceState) { } I'm just storing short term values so I don't want to use preferences. The problem is if a new activity opens those values are lost and I need them when the user goes back to the original activity. This was working. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: savedInstanceState always null
On Tue, Sep 20, 2011 at 12:21 PM, GregAZ ggur...@gmail.com wrote: But the problem still remains, the bundle is always null even though it is saved. Then a new instance of the Activity is being created. You can verify this by printing out the value of the Activity object itself in onSaveInstanceState and onCreate. Have you changed anything your manifest or launch flags with how you launch this Activity in particular? How does your Activity flow from the first instance to the next instance? - TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: savedInstanceState always null
On Tue, Sep 20, 2011 at 12:38 PM, GregAZ ggur...@gmail.com wrote: #3 is calling onCreate again. If instead of doing step 3 I hold home down and switch to the app it just resumes, onCreate isn't called again. Weirdballs. I'd do a full clean / rebuild, delete your shortcut (if that's what you're using) and reboot your device for shits and giggles. Odd things happen in software development ... - TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: savedInstanceState always null
The only thing I changed in the manifest was the versionCode and versionName. I had made a copy of the project, the renamed it (using Android tools through Eclipse) and discovered this problem. So I exported the original project, signed it, zip aligned it, put it on my phone and it too was doing it. This is very odd because I just put an update out for it about a month ago and it was fine. I hadn't touched it since. This is the only activity in the app. On Sep 20, 12:38 pm, TreKing treking...@gmail.com wrote: On Tue, Sep 20, 2011 at 12:21 PM, GregAZ ggur...@gmail.com wrote: But the problem still remains, the bundle is always null even though it is saved. Then a new instance of the Activity is being created. You can verify this by printing out the value of the Activity object itself in onSaveInstanceState and onCreate. Have you changed anything your manifest or launch flags with how you launch this Activity in particular? How does your Activity flow from the first instance to the next instance? --- -- TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: savedInstanceState always null
I assume that your activities have the default launch-mode. I.e. when started, they will be newly created. Press app-icon: Activity is started and onCreate is called. Press Home-button long time: Your task, that contains your activity, is brought to the foreground. If your process was still running, nothing really happens (onStart, onResume are called, though). Your 'saveInstanceState' in the onCreate is set to a non-null value if your activity has been created again due to a process re-creation, e.g. after your process had been killed for some reason (e.g. low memory). You can mimic this by starting your app, going to your activity, then bring another app in front of it (e.g. when a phone call comes in or by long-clicking home and selecting another app), then kill your process, then hit the back-button/key. Now you will go back to your app, your activity. But since your app's process was killed, your app and its activities need to be re-created. The 'saveInstanceState' won't be null (if you saved it in the onSaveInstanceState earlier). -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en