我在解析中有一个java bean类集值。我要求全局访问这个类,但是在使用它的实例静态并在其中赋值时给出空指针异常。代码如下:-
private String Responce;
private String Error;
private String Url;
private SIPModle objsip;
private VMModle objvmmodle;
private ArrayList<CustompadModle> objcmodlelist = new ArrayList<CustompadModle>();
private SettingModle objsettingmodle;
private WifiModle objwifimodle;
public String getResponce() {
return Responce;
}
public void setResponce(String responce) {
Responce = responce;
}
public String getError() {
return Error;
}
public void setError(String error) {
Error = error;
}
public ArrayList<CustompadModle> getObjcmodlelist() {
return objcmodlelist;
}
public void setObjcmodlelist(CustompadModle objcmodlelist) {
this.objcmodlelist.add(objcmodlelist);
}
public String getUrl() {
return Url;
}
public void setUrl(String url) {
Url = url;
}
public SIPModle getObjsip() {
return objsip;
}
public void setObjsip(SIPModle objsip) {
this.objsip = objsip;
}
public VMModle getObjvmmodle() {
return objvmmodle;
}
public void setObjvmmodle(VMModle objvmmodle) {
this.objvmmodle = objvmmodle;
}
public SettingModle getObjsettingmodle() {
return objsettingmodle;
}
public void setObjsettingmodle(SettingModle objsettingmodle) {
this.objsettingmodle = objsettingmodle;
}
public WifiModle getObjwifimodle() {
return objwifimodle;
}
public void setObjwifimodle(WifiModle objwifimodle) {
this.objwifimodle = objwifimodle;
}
我的要求是全局访问这个bean类。任何人都建议我
我在 doinbackground 中获取此对象并在该类的静态对象中分配为:AsyncTask {
ProgressDialog objprogress = new ProgressDialog(
UserSettingConfiguration.this);
ApplicationRequestHandler objhandler = new ApplicationRequestHandler();
@Override
protected void onPreExecute() {
this.objprogress.setMessage("Please Wait While Loading...");
this.objprogress.isShowing();
}
@Override
protected ConfigurationSttingModle doInBackground(String... params) {
objconfigsetting = objhandler.getConfigurationSetting(params[0],
params[1], params[2], params[3]);
return objconfigsetting;
}
@Override
protected void onPostExecute(ConfigurationSttingModle result) {
if (this.objprogress.isShowing()) {
this.objprogress.dismiss();
}
}
}
并在高级课程中使用;-
private static HashMap<String, String> SUMMARIES = new HashMap<String, String>() {
private static final long serialVersionUID = 3055562364235868653L;
{
String server = UserSettingConfiguration.objconfigsetting.getObjsip().getServer();
String displayname1 = UserSettingConfiguration.objconfigsetting.getObjsip().getUser();
String user = UserSettingConfiguration.objconfigsetting.getObjsip().getUser();
String password= UserSettingConfiguration.objconfigsetting.getObjsip().getPassword();
put(FIELD_DISPLAY_NAME,displayname1);// "90901");
put(FIELD_CALLER_ID,displayname1); //"90901");
put(FIELD_SERVER,server);
put(FIELD_USERNAME,user);
put(FIELD_AUTH_ID, "207");
put(FIELD_PASSWORD,password);
put(FIELD_PROXY, null);
}
};