Why is the location getTime lagging by 2-3 minutes
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

add a comment |
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

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
add a comment |
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

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


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
add a comment |
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
add a comment |
2 Answers
2
active
oldest
votes
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.
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 usemFusedLocationClient.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 asACCESS_COARSE_LOCATION
andACCESS_FINE_LOCATION
?
– Vadim Eksler
Nov 22 '18 at 11:13
add a comment |
For these case use
getElapsedRealtimeNanos() //Return the time of this fix, in elapsed real-time since system boot
refer
getTime vs getElapsedRealtimeNanos in Location
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
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 usemFusedLocationClient.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 asACCESS_COARSE_LOCATION
andACCESS_FINE_LOCATION
?
– Vadim Eksler
Nov 22 '18 at 11:13
add a comment |
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.
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 usemFusedLocationClient.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 asACCESS_COARSE_LOCATION
andACCESS_FINE_LOCATION
?
– Vadim Eksler
Nov 22 '18 at 11:13
add a comment |
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.
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.
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 usemFusedLocationClient.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 asACCESS_COARSE_LOCATION
andACCESS_FINE_LOCATION
?
– Vadim Eksler
Nov 22 '18 at 11:13
add a comment |
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 usemFusedLocationClient.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 asACCESS_COARSE_LOCATION
andACCESS_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
add a comment |
For these case use
getElapsedRealtimeNanos() //Return the time of this fix, in elapsed real-time since system boot
refer
getTime vs getElapsedRealtimeNanos in Location
add a comment |
For these case use
getElapsedRealtimeNanos() //Return the time of this fix, in elapsed real-time since system boot
refer
getTime vs getElapsedRealtimeNanos in Location
add a comment |
For these case use
getElapsedRealtimeNanos() //Return the time of this fix, in elapsed real-time since system boot
refer
getTime vs getElapsedRealtimeNanos in Location
For these case use
getElapsedRealtimeNanos() //Return the time of this fix, in elapsed real-time since system boot
refer
getTime vs getElapsedRealtimeNanos in Location
answered Nov 21 '18 at 6:33


sasikumarsasikumar
7,59711226
7,59711226
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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