如何EXCUTE Android中的AsyncTask里面onLocationChanged()方法 [英] How to excute AsyncTask inside onLocationChanged() method in Android

查看:189
本文介绍了如何EXCUTE Android中的AsyncTask里面onLocationChanged()方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有扩展的AsyncTask 类类和我创建这个类的此实例的AsyncTask 类使用的数据来自从GPS驱动程序从法

 公共无效onLocationChanged(地点){}

从接口 LocationListener的

我想知道为什么为什么应用程序执行方法的AsyncTask 实例onLocationChanged()?!因为我想只有当位置改变在后台执行的东西。


解决方案

 公共无效onLocationChanged(地点){        新yourAsyncTaksk(位置).execute();}

使一个构造函数为您的AsyncTask,用Location对象作为参数。<​​/ P>

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

解决方案

public void onLocationChanged(Location location) {

        new yourAsyncTaksk(location).execute();

}

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

这篇关于如何EXCUTE Android中的AsyncTask里面onLocationChanged()方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆