How to excute AsyncTask inside onLocationChanged()

2019-08-28 21:52发布

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条回答
叼着烟拽天下
2楼-- · 2019-08-28 22:15
public void onLocationChanged(Location location) {

        new yourAsyncTaksk(location).execute();

}

make a constructor for your asyncTask , with Location object as argument.

查看更多
登录 后发表回答