0
我已經創建了兩個AsyncTask
,但是當我傳遞第一個asyn任務的輸出是第二個asyn任務的輸入時,它是空的 這裏是我的代碼。AsyncTask onPostExecute空指針異常
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;
}
}
發佈您的堆棧跟蹤。並向我們展示如何調用'AsyncTask'。 –
「點」在哪裏申報?宣告「point_to_be_send」在哪裏?哪一行拋出異常? –
我已更新我的問題,對於由此造成的不便深表歉意 – user1115684