How to update longitude and latitude in every 10 seconds in mysql database?

前端 未结 3 593
鱼传尺愫
鱼传尺愫 2020-12-22 00:52

I\'m trying to get latitude and longitude from Android device and send it to MySQL database. when any one register his current latitude and longitude saved in the database.b

3条回答
  •  南方客
    南方客 (楼主)
    2020-12-22 01:22

    You have to use threads for this purpose , with time out of 10 seconds so every 10 seconds your code in thread will run

     new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                // This method will be executed once the timer is over
                // insert your data to db here
    
    
                // close this activity
                finish();
            }
        }, TIME_OUT);
    

    And set time out as

    private static int TIME_OUT = 10000;
    

    Here you go :)

提交回复
热议问题