Dee*_*ary 2 java singleton android
我知道Singleton,但我无法在Android项目中使用它.我是Android的初学者.请告诉我在大型数据的Android项目中如何以及在哪里使用Singleton.我用它来做简单的价值观.
Giv*_*ivi 41
Android中的Singleton与Java中的Singleton相同:
一个基本的Singleton类示例:
public class AppManager
{
private static AppManager _instance;
private AppManager()
{
}
public synchronized static AppManager getInstance()
{
if (_instance == null)
{
_instance = new AppManager();
}
return _instance;
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
28040 次 |
| 最近记录: |