开发者

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

开发者 https://www.devze.com 2023-01-27 00:26 出处:网络
I made two Buttons in my Android application. the first one activates sending my GPS data to a Website.

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

精彩评论

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