Why is the location getTime lagging by 2-3 minutes












0















I am listening to location Updates by using



locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 0, this);


and when I get the location in



@Override
public void onLocationChanged(final Location location)
{
DateFormat dateFormat = new SimpleDateFormat("E MM/dd/yyyy hh:mm:ss a");
Log.d("OnLocationChange: ", dateFormat.format(location.getTime());
}


The date and time displayed is 2 to 3 minutes delayed. Can someone tell me why










share|improve this question























  • Is it in background (Service)?

    – ADM
    Nov 21 '18 at 6:29






  • 1





    gps will take time to take the location. specially for the first time to locate exact position. also that depends on the GPS signal strength ,hardware etc.

    – Chamila Lakmal
    Nov 21 '18 at 6:51











  • Go for the FusedLocationProvider it will return last known location much quicker

    – Chamila Lakmal
    Nov 21 '18 at 6:52
















0















I am listening to location Updates by using



locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 0, this);


and when I get the location in



@Override
public void onLocationChanged(final Location location)
{
DateFormat dateFormat = new SimpleDateFormat("E MM/dd/yyyy hh:mm:ss a");
Log.d("OnLocationChange: ", dateFormat.format(location.getTime());
}


The date and time displayed is 2 to 3 minutes delayed. Can someone tell me why










share|improve this question























  • Is it in background (Service)?

    – ADM
    Nov 21 '18 at 6:29






  • 1





    gps will take time to take the location. specially for the first time to locate exact position. also that depends on the GPS signal strength ,hardware etc.

    – Chamila Lakmal
    Nov 21 '18 at 6:51











  • Go for the FusedLocationProvider it will return last known location much quicker

    – Chamila Lakmal
    Nov 21 '18 at 6:52














0












0








0








I am listening to location Updates by using



locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 0, this);


and when I get the location in



@Override
public void onLocationChanged(final Location location)
{
DateFormat dateFormat = new SimpleDateFormat("E MM/dd/yyyy hh:mm:ss a");
Log.d("OnLocationChange: ", dateFormat.format(location.getTime());
}


The date and time displayed is 2 to 3 minutes delayed. Can someone tell me why










share|improve this question














I am listening to location Updates by using



locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 0, this);


and when I get the location in



@Override
public void onLocationChanged(final Location location)
{
DateFormat dateFormat = new SimpleDateFormat("E MM/dd/yyyy hh:mm:ss a");
Log.d("OnLocationChange: ", dateFormat.format(location.getTime());
}


The date and time displayed is 2 to 3 minutes delayed. Can someone tell me why







android geolocation






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 21 '18 at 6:24









mckmck

12




12













  • Is it in background (Service)?

    – ADM
    Nov 21 '18 at 6:29






  • 1





    gps will take time to take the location. specially for the first time to locate exact position. also that depends on the GPS signal strength ,hardware etc.

    – Chamila Lakmal
    Nov 21 '18 at 6:51











  • Go for the FusedLocationProvider it will return last known location much quicker

    – Chamila Lakmal
    Nov 21 '18 at 6:52



















  • Is it in background (Service)?

    – ADM
    Nov 21 '18 at 6:29






  • 1





    gps will take time to take the location. specially for the first time to locate exact position. also that depends on the GPS signal strength ,hardware etc.

    – Chamila Lakmal
    Nov 21 '18 at 6:51











  • Go for the FusedLocationProvider it will return last known location much quicker

    – Chamila Lakmal
    Nov 21 '18 at 6:52

















Is it in background (Service)?

– ADM
Nov 21 '18 at 6:29





Is it in background (Service)?

– ADM
Nov 21 '18 at 6:29




1




1





gps will take time to take the location. specially for the first time to locate exact position. also that depends on the GPS signal strength ,hardware etc.

– Chamila Lakmal
Nov 21 '18 at 6:51





gps will take time to take the location. specially for the first time to locate exact position. also that depends on the GPS signal strength ,hardware etc.

– Chamila Lakmal
Nov 21 '18 at 6:51













Go for the FusedLocationProvider it will return last known location much quicker

– Chamila Lakmal
Nov 21 '18 at 6:52





Go for the FusedLocationProvider it will return last known location much quicker

– Chamila Lakmal
Nov 21 '18 at 6:52












2 Answers
2






active

oldest

votes


















0














I advise you to use new FusedLocationProviderClient, it's more stable and faster than old api's, also it easy to use. You can look at my example here Android - My app can get location information until opening Google Maps although it has related permissions, there i put links to documentations.






share|improve this answer
























  • I changed my code to use FusedLocationProviderClient but there is still a 2-3 Minute delay.

    – mck
    Nov 22 '18 at 0:40











  • And you use mFusedLocationClient.requestLocationUpdates what is your LocationRequest settings that you send to this function, first parameter?

    – Vadim Eksler
    Nov 22 '18 at 11:11











  • do you use two manifest permission as ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION?

    – Vadim Eksler
    Nov 22 '18 at 11:13



















0














For these case use



getElapsedRealtimeNanos() //Return the time of this fix, in elapsed real-time since system boot


refer



getTime vs getElapsedRealtimeNanos in Location






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53406324%2fwhy-is-the-location-gettime-lagging-by-2-3-minutes%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    I advise you to use new FusedLocationProviderClient, it's more stable and faster than old api's, also it easy to use. You can look at my example here Android - My app can get location information until opening Google Maps although it has related permissions, there i put links to documentations.






    share|improve this answer
























    • I changed my code to use FusedLocationProviderClient but there is still a 2-3 Minute delay.

      – mck
      Nov 22 '18 at 0:40











    • And you use mFusedLocationClient.requestLocationUpdates what is your LocationRequest settings that you send to this function, first parameter?

      – Vadim Eksler
      Nov 22 '18 at 11:11











    • do you use two manifest permission as ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION?

      – Vadim Eksler
      Nov 22 '18 at 11:13
















    0














    I advise you to use new FusedLocationProviderClient, it's more stable and faster than old api's, also it easy to use. You can look at my example here Android - My app can get location information until opening Google Maps although it has related permissions, there i put links to documentations.






    share|improve this answer
























    • I changed my code to use FusedLocationProviderClient but there is still a 2-3 Minute delay.

      – mck
      Nov 22 '18 at 0:40











    • And you use mFusedLocationClient.requestLocationUpdates what is your LocationRequest settings that you send to this function, first parameter?

      – Vadim Eksler
      Nov 22 '18 at 11:11











    • do you use two manifest permission as ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION?

      – Vadim Eksler
      Nov 22 '18 at 11:13














    0












    0








    0







    I advise you to use new FusedLocationProviderClient, it's more stable and faster than old api's, also it easy to use. You can look at my example here Android - My app can get location information until opening Google Maps although it has related permissions, there i put links to documentations.






    share|improve this answer













    I advise you to use new FusedLocationProviderClient, it's more stable and faster than old api's, also it easy to use. You can look at my example here Android - My app can get location information until opening Google Maps although it has related permissions, there i put links to documentations.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 21 '18 at 6:29









    Vadim EkslerVadim Eksler

    444215




    444215













    • I changed my code to use FusedLocationProviderClient but there is still a 2-3 Minute delay.

      – mck
      Nov 22 '18 at 0:40











    • And you use mFusedLocationClient.requestLocationUpdates what is your LocationRequest settings that you send to this function, first parameter?

      – Vadim Eksler
      Nov 22 '18 at 11:11











    • do you use two manifest permission as ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION?

      – Vadim Eksler
      Nov 22 '18 at 11:13



















    • I changed my code to use FusedLocationProviderClient but there is still a 2-3 Minute delay.

      – mck
      Nov 22 '18 at 0:40











    • And you use mFusedLocationClient.requestLocationUpdates what is your LocationRequest settings that you send to this function, first parameter?

      – Vadim Eksler
      Nov 22 '18 at 11:11











    • do you use two manifest permission as ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION?

      – Vadim Eksler
      Nov 22 '18 at 11:13

















    I changed my code to use FusedLocationProviderClient but there is still a 2-3 Minute delay.

    – mck
    Nov 22 '18 at 0:40





    I changed my code to use FusedLocationProviderClient but there is still a 2-3 Minute delay.

    – mck
    Nov 22 '18 at 0:40













    And you use mFusedLocationClient.requestLocationUpdates what is your LocationRequest settings that you send to this function, first parameter?

    – Vadim Eksler
    Nov 22 '18 at 11:11





    And you use mFusedLocationClient.requestLocationUpdates what is your LocationRequest settings that you send to this function, first parameter?

    – Vadim Eksler
    Nov 22 '18 at 11:11













    do you use two manifest permission as ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION?

    – Vadim Eksler
    Nov 22 '18 at 11:13





    do you use two manifest permission as ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION?

    – Vadim Eksler
    Nov 22 '18 at 11:13













    0














    For these case use



    getElapsedRealtimeNanos() //Return the time of this fix, in elapsed real-time since system boot


    refer



    getTime vs getElapsedRealtimeNanos in Location






    share|improve this answer




























      0














      For these case use



      getElapsedRealtimeNanos() //Return the time of this fix, in elapsed real-time since system boot


      refer



      getTime vs getElapsedRealtimeNanos in Location






      share|improve this answer


























        0












        0








        0







        For these case use



        getElapsedRealtimeNanos() //Return the time of this fix, in elapsed real-time since system boot


        refer



        getTime vs getElapsedRealtimeNanos in Location






        share|improve this answer













        For these case use



        getElapsedRealtimeNanos() //Return the time of this fix, in elapsed real-time since system boot


        refer



        getTime vs getElapsedRealtimeNanos in Location







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 21 '18 at 6:33









        sasikumarsasikumar

        7,59711226




        7,59711226






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53406324%2fwhy-is-the-location-gettime-lagging-by-2-3-minutes%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            MongoDB - Not Authorized To Execute Command

            How to fix TextFormField cause rebuild widget in Flutter

            in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith