0

我在从应用程序扩展的类中设置全局变量。只是对基础知识感到困惑。以下代码正在运行,但它是正确的方法吗?

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() 和构造函数都可以吗?

4

1 回答 1

0

看起来不错,你也可以写:

private String userid="000000";
private String pwd;
private String name;
private String station;

麦芽酒删除 c-tor

于 2012-04-16T17:02:47.467 回答