Thursday, May 3, 2012

Re: [android-developers] Re: Singletons in Android .... Final solution?

On Thu, May 3, 2012 at 6:16 PM, blake <blake.meike@gmail.com> wrote:
> Romain,
>  I have have the following code
>
> public class SandboxApplication extends Application {
>    public static enum Romain {
>        SINGLETON;
>        private final long now = System .currentTimeMillis();
>        @Override public String toString() { return super.toString() +
> "@" + now; }
>    }
>
>     @Override public void onCreate() {
>        super.onCreate();
>        Log.d("####", Romain.SINGLETON.toString());
>    }
>
> I am quite certain that I have seen this application log different
> times, from that log statement, over the life of the application.

As I indicated to somebody else on this thread, create an app that
reliably reproduces this problem, and post it somewhere.

> Oddly, I'm fairly certain that I've seen it log different times even
> *without* an intervening call to onTerminate.

onTerminate() is never called on an Application, despite the docs. The
Application object goes away when the process does.

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android Training...At Your Office: http://commonsware.com/training

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate