Interesting. I have seen ACRA crashes in my app but didn't know what to do about them. Now at least I have an explanation. But this doesn't explain why my app is behaving as if its preferences have been reset.
We've established that onCreate is being called multiple times. We've also established that this is not necessarily a bad thing (although it's bad if the app has not been killed in the interim). Am I misunderstanding how to use preferences? When an app gets created it is given a context. When an app get *re*created via a second kills to onCreate (following a kill) does it get the same context? If that is not guaranteed then should I not be using context-based preferences to persist my data? Is there something other than PreferenceManager.getDefaultSharedPreference to do this? For what it's worth, I am using these shared preferences to store values from my Preferences screen AND so store certain state information for the application. ...Jake >>>>> "ZV" == Zsolt Vasvari <zvasv...@gmail.com> writes: ZV> This happens to my app very infrequently also. I also use ACRA ZV> and ACRA crashes because it detects that its init() method was ZV> called twice (from Application.onCreate()) ZV> The only way ACRA init knows that it was called twice is if it ZV> wasn't killed between invocations. So this is almost certainly ZV> an Android/vendor bug where it calls onCreate() multiple times ZV> under some special conditions without killing the app in between ZV> the calls. ZV> On Friday, January 18, 2013 11:29:37 AM UTC+8, Jake Colman wrote: >> >> >>>>> "T" == TreKing <treki...@gmail.com <javascript:>> writes: >> T> On Thu, Jan 17, 2013 at 4:14 PM, Jake Colman T> <col...@ppllc.com<javascript:>> >> wrote: >> >> >> When the application is recreated I assume that it loses the >> >> previous incarnations shared preferences and, therefore, the >> >> service doesn't know that it already triggered. Hence, the false >> >> trigger when the application is recreated. >> >> >> T> SharedPreferences are persisted if you commit them so any prefs T> you set in one call to Application.onCreate() should be available T> in the next call and throughout the rest of the app. >> >> I am using PreferenceManager.getDefaultSharedPreference. I am >> committing my preferences when my Service (not the widget receiver but >> the Service that is started by the widget receiver) is destroyed and I >> read the preferences when the Service is created. One of the saved >> pieces of data stores whether the notification had already been >> triggered. Since the getDefaultSharedPreference method takes a context, >> is it possible that when the Application is recreated there is a new >> context so my saved preferences are lost? That would explain why the >> notification is re-triggered when the Application is created a second >> time. >> >> -- >> Jake Colman -- Android Tinkerer >> >> ZV> -- ZV> You received this message because you are subscribed to the Google ZV> Groups "Android Developers" group. ZV> To post to this group, send email to android-developers@googlegroups.com ZV> To unsubscribe from this group, send email to ZV> android-developers+unsubscr...@googlegroups.com ZV> For more options, visit this group at ZV> http://groups.google.com/group/android-developers?hl=en -- Jake Colman -- Android Tinkerer -- 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