嘿,我制作了一个应用程序,其中有三个asynchronus类正在运行...它工作了一段时间,有时候其中一个类没有返回值......
这是我的代码......
public class DetailsTenderActivity extends Activity {
final String url_bidnemo="http://www.myserver.com/index.php";
public static DefaultHttpClient client;
private static final String DEFAULT = "N/A";
String tender_id="";
String user_id="";
TextView basic_dets;
TextView other_dets;
TextView item_dets;
public final static String EXTRA_MESSAGE6 = "com.mobile.bidnemo.MESSAGE6";
public final static String EXTRA_MESSAGE7 = "com.mobile.bidnemo.MESSAGE7";
public final static String EXTRA_MESSAGE8 = "com.mobile.bidnemo.MESSAGE8";
public final static String EXTRA_MESSAGE9 = "com.mobile.bidnemo.MESSAGE9";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_details_tender);
setTitle("Tender details");
Downloadbasic dw_basic=new Downloadbasic();
dw_basic.execute();
Downloadother dw_other=new Downloadother();
dw_other.execute();
Downloaditems dw_items=new Downloaditems();
dw_items.execute();
final ProgressDialog pd=new ProgressDialog(this);
pd.setProgressStyle(ProgressDialog.STYLE_SPINNER);
pd.setMessage("Please wait..");
pd.setIndeterminate(true);
pd.setCancelable(true);
/**check session exist or not start****************************/
SharedPreferences share= getSharedPreferences("Userdata", Context.MODE_PRIVATE);
String val=share.getString("session_value", DEFAULT);
if(DEFAULT.equals(val)){
Intent intent=new Intent(DetailsTenderActivity.this,Main.class);
startActivity(intent);
}
else{
Intent intent = getIntent();
tender_id = intent.getStringExtra(TenderViewActivity.EXTRA_MESSAGE2);
user_id=val;
// basic_dets.setText(details_info("basic"));
// other_dets.setText(details_info("other"));
// item_dets.setText(item_info());
Button bid_button=(Button) findViewById(R.id.button1);
bid_button.setText(bid_activity_info());
}
/**check session exist or not end*****************************/
/**Place bid process start*******/
Button place_bid=(Button) findViewById(R.id.button1);
place_bid.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
pd.show();
Intent intent=new Intent(DetailsTenderActivity.this,PlaceBidActivity.class);
intent.putExtra(EXTRA_MESSAGE6, tender_id);
intent.putExtra(EXTRA_MESSAGE7, user_id);
intent.putExtra(EXTRA_MESSAGE8, bid_activity_info());
intent.putExtra(EXTRA_MESSAGE9, partial_check());
startActivity(intent);
}
});
/**Place bid process end*********/
placebid_button_prop();
}//onCreate
@SuppressWarnings("unused")
private class Downloadbasic extends AsyncTask<String, String, String> {
@Override
protected String doInBackground(String... params) {
String getval=details_info("basic");
return getval;
}
protected void onPostExecute(String result) {
super.onPostExecute(result);
TextView basic_dets=(TextView) findViewById(R.id.basic_details);
basic_dets.setText(result);
}
}
@SuppressWarnings("unused")
private class Downloadother extends AsyncTask<String, String, String> {
@Override
protected String doInBackground(String... params) {
String getval=details_info("other");
return getval;
}
protected void onPostExecute(String result) {
TextView other_dets=(TextView) findViewById(R.id.other_details);
other_dets.setText(result);
}
}
@SuppressWarnings("unused")
private class Downloaditems extends AsyncTask<String, String, String> {
@Override
protected String doInBackground(String... params) {
String getval=item_info();
return getval;
}
protected void onPostExecute(String result) {
TextView item_dets=(TextView) findViewById(R.id.item_details);
item_dets.setText(result);
}
}
上面的代码工作正常,但大多数时候一两个asynchrouns类没有返回结果它仍然是空白的...不知道为什么......