我已经创建了两个AsyncTask
,但是当我将第一个异步任务的输出(即 Geopoint)作为输入传递给第二个异步任务时,它为空 这是我的代码。
String input=EnterYourSearch.getText().toString();
Geopoint point_to_be_send;
get_location.execute(input);
getplaces.execute(point_to_be_send);
public class Getlocation extends AsyncTask<String, String, Geopoint>
{
@Override
protected Geopoint doInBackground(String... params) {
jsonobject=JsonRequest.getLocationInfo(params[0]);
point=JsonRequest.getLatLong(jsonobject);
return point;
}
@Override
protected void onPostExecute( Geopoint point) {
if(point.lat !=0)
{
//check=false;
point_to_be_send=point;
}
}
}
public class Getplaces extends AsyncTask<Geopoint, String, Boolean>
{
@Override
protected Boolean doInBackground(Geopoint... params) {
// TODO Auto-generated method stub
googleplaces=new Googleplaces();
try {
googleplaces.search(params[0].lat, params[0].lon, 1000, null);
} catch (Exception e) {
// TODO Auto-generated catch block
Log.d("Error", e.toString());
e.printStackTrace();
}
return true;
}
这是 Geopoint 类
public class Geopoint {
public double lat;
public double lon;
public Geopoint(double i, double j) {
// TODO Auto-generated constructor stub
lat=i;
lon=j;
}
}