开发者

When a Button is enabled send the GPS data just when the Location changes

I made two Buttons in my Android application. the first one activates sending my GPS data to a Website. the second one disables this option. so my question is:

What can I do to make it possible that when my activatebutton.isEnabled()==false (already pushed) is,that each time when my location changes a method will be exec开发者_运维百科uted.


Register a LocationListener with an onLocationChanged() method using requestLocationUpdates when the enable is clicked, and remove it when the disable is clicked. Here's an example.


If you are requesting locationUpdates, don't forget to unregister the updates by overriding the onPause and onStop and re-registering in the onResume, otherwise it will be a huge battery drain.

http://developer.android.com/guide/topics/location/obtaining-user-location.html

Should cover everything you need to know.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜