how to get gps location android

前端 未结 5 1476
有刺的猬
有刺的猬 2020-12-08 17:32

I am trying to have a constant gps listener that will send its location (long and lat coordinates) to a web server every x mins. On a button click it will also send its loca

5条回答
  •  生来不讨喜
    2020-12-08 18:24

    One method is to use Timer and TimerTask

    Timer timer = new Timer();
    timer.scheduleAtFixedRate(new SendLocationTask(), 0, 60000);
    
    class SendLocationTask extends TimerTask{
        public abstract void run(){
            // send position info here
        }
    }
    

提交回复
热议问题