How to excute AsyncTask inside onLocationChanged() method in Android

≡放荡痞女 提交于 2019-12-13 04:33:53

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!