1.
private static MyApplication instance;
public static MyApplication getInstance() {
return instance;
}
@Override
public void onCreate() {
// TODO Auto-generated method stub
super.onCreate();
instance = this;
}
}
2.在manifest中<application>中加入name="mypackage.MyApplication"
3.在任意类中使用MyApplication.getInstance()来获取应用程序Context了。