前面做了几个模块都没问题 就这个有问题。。
calthread=new CalThread();
calthread.start();
calthread.mHandler.sendEmptyMessage(0*123);//在这报错
错误信息:
Caused by: java.lang.NullPointerException
at com.example.lwd_community.Personalinfo.onCreate(Personalinfo.java:62)
class CalThread extends Thread{
public Handler mHandler;
public void run(){
Looper.prepare();
mHandler=new Handler(){
public void handleMessage(android.os.Message msg) {
if(msg.what==0*123){
HttpGet get=new HttpGet("http://10.224.40.158:8080/Community/OnlinePay.jsp");
get.setHeader("Cookie", Util.getPreference(Personalinfo.this, "cookie"));
try {
HttpResponse response=httpClient.execute(get);
if(response.getStatusLine().getStatusCode()==HttpStatus.SC_OK){
String content=EntityUtils.toString(response.getEntity());
String result=(content.substring(content.indexOf("")+6, content.indexOf(""))).trim();
System.out.println(result+"--------");
}
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
};
};
Looper.loop();
}
}