user1143989 user1143989 - 1 year ago 199
Android Question

Android extends Application basics

I am setting global variables in a class which extends from Application. Just getting confused with the basics. The the following code is working but is it a right way to do it ?

public class GlobalMV extends Application{

private static final String TAG = "Global";
private String userid, pwd, name, station;

@Override public void onCreate ()
new UncaughtExceptionHandler(){
public void uncaughtException(Thread arg0, Throwable arg1) {
Functions.CustomToastLong(getApplicationContext(), arg0.toString() + arg1.toString());

public GlobalMV(){
userid ="000000";

Is onCreate() and constructor both can be there ?

Answer Source

looks fine, you can also write:

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

ale remove c-tor

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download