Singletons vs. Application Context in Android?

后端 未结 10 1334
醉话见心
醉话见心 2020-11-22 03:11

Recalling this post enumerating several problems of using singletons and having seen several examples of Android applications using singleton pattern, I wonder if it\'s a go

10条回答
  •  旧巷少年郎
    2020-11-22 03:28

    They're actually the same. There's one difference I can see. With Application class you can initialize your variables in Application.onCreate() and destroy them in Application.onTerminate(). With singleton you have to rely VM initializing and destroying statics.

提交回复
热议问题