问题
I have class that extends AsyncTask class and I create instance of this class of this AsyncTask class uses data comes from GPS driver from the method
public void onLocationChanged(Location location) {}
from interface LocationListener.
I want to know why why the application to execute AsyncTask instance inside the method onLocationChanged() ?! As I want to execute something in background only when the location is changed
回答1:
public void onLocationChanged(Location location) {
new yourAsyncTaksk(location).execute();
}
make a constructor for your asyncTask , with Location object as argument.
来源:https://stackoverflow.com/questions/8253887/how-to-excute-asynctask-inside-onlocationchanged-method-in-android