0
두 개의 AsyncTask
을 만들었지 만 두 번째 asyn 작업에 대한 입력으로 Geopoint 인 첫 번째 asyn 작업의 출력을 전달할 때 여기 내 코드입니다.AsyncTask onPostExecute NullPointerException
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;
}
그리고 이것은 당신이 예외를 얻고있는 이유 point_to_be_send
이
Geopoint point_to_be_send = new Geopoint(myDoubleI, myDoubleJ);
point_to_be_send is null
그게 전부 같은 것을 추가 초기화 실패
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'는 어디에 선언 되었습니까? 'point_to_be_send'가 선언 된 곳은 어디입니까? 어떤 라인이 예외를 던지고 있습니까? –
불편을 끼쳐 드려 죄송합니다. – user1115684