//当我调试此代码时,编译器不编译ContactList.java,因此循环进入无限状态
// Contact.java类
rslt = "START";
ContactList.userid=getIntent().getStringExtra("userID").toString();
ContactList con = new ContactList();
con.join();
con.start();
//here control do not go to ContactList.java
Log.i("JSONObject", rslt);
while (rslt == "START") {
try {
Thread.sleep(10);
} catch (Exception ex) {
Toast.makeText(getApplicationContext(), "Error Occured Login Again..!!", Toast.LENGTH_LONG).show();
}
}
我的ContactList.java是:
public class ContactList extends Thread {
public WebServices cs;
public static String userid;
public void run(){
try{
cs=new WebServices();
String resp=cs.contactlistcall(userid); **\\webservice method**
Contact.rslt = resp;
}catch(Exception ex)
{
Contact.rslt=ex.toString();
}
}
}
//这个resp来自我的sql server数据库,通过.net webservice
答案 0 :(得分:-1)
使用String比较警告,因为String是Object而不是基本类型:
while (rslt == "START")
应该是
while (rslt.equals("START"))
修改强>
Contact.java
while (con.getRslt().equals("START"))