我在从应用程序扩展的类中设置全局变量。只是对基础知识感到困惑。以下代码正在运行,但它是正确的方法吗?
public class GlobalMV extends Application{
private static final String TAG = "Global";
private String userid, pwd, name, station;
@Override public void onCreate ()
{
Thread.setDefaultUncaughtExceptionHandler(
new UncaughtExceptionHandler(){
@Override
public void uncaughtException(Thread arg0, Throwable arg1) {
Functions.CustomToastLong(getApplicationContext(), arg0.toString() + arg1.toString());
}
}
);
super.onCreate();
}
public GlobalMV(){
userid ="000000";
pwd="";
}
onCreate() 和构造函数都可以吗?