Fused Location Provider setSmallestDisplacement not working in specific movement
I tried to get user location when user was movement. I wrote below code and i set smallest displacement to 30 meter and interval to 0 millisecond that i get location in every 30 meter movement but my application not worked correct. If i stop in a place, the application didn't get location and this is true but when i moved, sometimes i get location in 100 meter movement or more. Why?
If i get location in more than 30 meter, i lost some points and this is important for me.
This is My Code for request location update:
private void createLocationRequest() {
mLocationRequest = new LocationRequest();
mLocationRequest.setInterval(0);//(UPDATE_INTERVAL_IN_MILLISECONDS);
mLocationRequest.setFastestInterval(0);//(FASTEST_UPDATE_INTERVAL_IN_MILLISECONDS);
mLocationRequest.setSmallestDisplacement(30);
mLocationRequest.setMaxWaitTime(MAX_WAITE_TIME);
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
}
add a comment |
I tried to get user location when user was movement. I wrote below code and i set smallest displacement to 30 meter and interval to 0 millisecond that i get location in every 30 meter movement but my application not worked correct. If i stop in a place, the application didn't get location and this is true but when i moved, sometimes i get location in 100 meter movement or more. Why?
If i get location in more than 30 meter, i lost some points and this is important for me.
This is My Code for request location update:
private void createLocationRequest() {
mLocationRequest = new LocationRequest();
mLocationRequest.setInterval(0);//(UPDATE_INTERVAL_IN_MILLISECONDS);
mLocationRequest.setFastestInterval(0);//(FASTEST_UPDATE_INTERVAL_IN_MILLISECONDS);
mLocationRequest.setSmallestDisplacement(30);
mLocationRequest.setMaxWaitTime(MAX_WAITE_TIME);
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
}
add a comment |
I tried to get user location when user was movement. I wrote below code and i set smallest displacement to 30 meter and interval to 0 millisecond that i get location in every 30 meter movement but my application not worked correct. If i stop in a place, the application didn't get location and this is true but when i moved, sometimes i get location in 100 meter movement or more. Why?
If i get location in more than 30 meter, i lost some points and this is important for me.
This is My Code for request location update:
private void createLocationRequest() {
mLocationRequest = new LocationRequest();
mLocationRequest.setInterval(0);//(UPDATE_INTERVAL_IN_MILLISECONDS);
mLocationRequest.setFastestInterval(0);//(FASTEST_UPDATE_INTERVAL_IN_MILLISECONDS);
mLocationRequest.setSmallestDisplacement(30);
mLocationRequest.setMaxWaitTime(MAX_WAITE_TIME);
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
}
I tried to get user location when user was movement. I wrote below code and i set smallest displacement to 30 meter and interval to 0 millisecond that i get location in every 30 meter movement but my application not worked correct. If i stop in a place, the application didn't get location and this is true but when i moved, sometimes i get location in 100 meter movement or more. Why?
If i get location in more than 30 meter, i lost some points and this is important for me.
This is My Code for request location update:
private void createLocationRequest() {
mLocationRequest = new LocationRequest();
mLocationRequest.setInterval(0);//(UPDATE_INTERVAL_IN_MILLISECONDS);
mLocationRequest.setFastestInterval(0);//(FASTEST_UPDATE_INTERVAL_IN_MILLISECONDS);
mLocationRequest.setSmallestDisplacement(30);
mLocationRequest.setMaxWaitTime(MAX_WAITE_TIME);
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
}
asked Jan 20 at 6:37
Fahimeh HashemianFahimeh Hashemian
12
12
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
LocationRequest.setSmallestDisplacement doesn't give you a better accuracy, it's just to avoid unnecessary updates.
There is no method to enhance low accuracy, you just get a point with some accuracy, if you are not interested in positions with low accuracy just skip this location and wait for a better one.
No perfect accuracy is available now, the accuracy is 100m for worse accuracy.
check android developers page for more information:
https://developer.android.com/training/location/receive-location-updates#location-request
Try this:
Set the accuracy level to ACCURACY_FINE
Set the highest power (to get best GPS signal)
Don’t request the altitude.
Set speedRequired to false
Set CostAllowed flag to true
Set BearingRequired to false
Set HorizontalAccuracy and VerticalAccuracy to HIGH
read more about these function, you will understand why.
Criteria tenM= new Criteria();
tenM.setAccuracy(Criteria.ACCURACY_FINE);
tenM.setPowerRequirement(Criteria.POWER_HIGH);
tenM.setAltitudeRequired(false);
tenM.setSpeedRequired(false);
tenM.setCostAllowed(true);
tenM.setBearingRequired(false);
tenM.setHorizontalAccuracy(Criteria.ACCURACY_HIGH);
tenM.setVerticalAccuracy(Criteria.ACCURACY_HIGH);
locationManager.requestLocationUpdates(1000 /*milliseconds*/, 1
/*1 meter*/,
tenM /*criteria*/, this /*context*/, null);
Thanks for your reply @KARAM JABER. Do you mean, i can't get location after 30 meter movement? and i just set displacement upper than 100 meter? I need update location after 30 meter in out door.
– Fahimeh Hashemian
Jan 20 at 8:47
you can get the location after 30m but the problem its not perfect accuracy, so after setting your smallest displacement, the location request will fire only if you surpassed that displacement on the next update, if not it will not. now it will keep checking, if the new position is with low accuracy, you should skip that one and wait for the more accurate one, but by that time you would have moved more than 30m and you will be waiting for the next one. Even big companies such as whatsapp and facebook when sending location is only accurate to 20m-30m minimum.
– KARAM JABER
Jan 20 at 9:36
Thanks @KARAM JABER. If i don't skip that low accuracy location, what happened? and How works applications like waze? The waze get location periodically and show my location in every millisecond!
– Fahimeh Hashemian
Jan 20 at 11:16
@FahimehHashemian you will get an undesired behavior, like what you are getting right now for 100m and not 30m. Check this edit for my answer, i got as accurate as 10m using.
– KARAM JABER
Jan 20 at 11:20
Finally @FahimehHashemian please setInterval not fastestInterval, setInterval is called faster than fastestInterval. The Irony
– KARAM JABER
Jan 20 at 11:28
|
show 3 more comments
That's because your location accuracy is above 30m (presumably much higher). So when you change your location by 100 m, you are still in the estimated location circle. You can get location accuracy to see if true, but anyway you don't have a better choice than get coordinates frequently and choose the one with most accuracy.
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%2f54274184%2ffused-location-provider-setsmallestdisplacement-not-working-in-specific-movement%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
LocationRequest.setSmallestDisplacement doesn't give you a better accuracy, it's just to avoid unnecessary updates.
There is no method to enhance low accuracy, you just get a point with some accuracy, if you are not interested in positions with low accuracy just skip this location and wait for a better one.
No perfect accuracy is available now, the accuracy is 100m for worse accuracy.
check android developers page for more information:
https://developer.android.com/training/location/receive-location-updates#location-request
Try this:
Set the accuracy level to ACCURACY_FINE
Set the highest power (to get best GPS signal)
Don’t request the altitude.
Set speedRequired to false
Set CostAllowed flag to true
Set BearingRequired to false
Set HorizontalAccuracy and VerticalAccuracy to HIGH
read more about these function, you will understand why.
Criteria tenM= new Criteria();
tenM.setAccuracy(Criteria.ACCURACY_FINE);
tenM.setPowerRequirement(Criteria.POWER_HIGH);
tenM.setAltitudeRequired(false);
tenM.setSpeedRequired(false);
tenM.setCostAllowed(true);
tenM.setBearingRequired(false);
tenM.setHorizontalAccuracy(Criteria.ACCURACY_HIGH);
tenM.setVerticalAccuracy(Criteria.ACCURACY_HIGH);
locationManager.requestLocationUpdates(1000 /*milliseconds*/, 1
/*1 meter*/,
tenM /*criteria*/, this /*context*/, null);
Thanks for your reply @KARAM JABER. Do you mean, i can't get location after 30 meter movement? and i just set displacement upper than 100 meter? I need update location after 30 meter in out door.
– Fahimeh Hashemian
Jan 20 at 8:47
you can get the location after 30m but the problem its not perfect accuracy, so after setting your smallest displacement, the location request will fire only if you surpassed that displacement on the next update, if not it will not. now it will keep checking, if the new position is with low accuracy, you should skip that one and wait for the more accurate one, but by that time you would have moved more than 30m and you will be waiting for the next one. Even big companies such as whatsapp and facebook when sending location is only accurate to 20m-30m minimum.
– KARAM JABER
Jan 20 at 9:36
Thanks @KARAM JABER. If i don't skip that low accuracy location, what happened? and How works applications like waze? The waze get location periodically and show my location in every millisecond!
– Fahimeh Hashemian
Jan 20 at 11:16
@FahimehHashemian you will get an undesired behavior, like what you are getting right now for 100m and not 30m. Check this edit for my answer, i got as accurate as 10m using.
– KARAM JABER
Jan 20 at 11:20
Finally @FahimehHashemian please setInterval not fastestInterval, setInterval is called faster than fastestInterval. The Irony
– KARAM JABER
Jan 20 at 11:28
|
show 3 more comments
LocationRequest.setSmallestDisplacement doesn't give you a better accuracy, it's just to avoid unnecessary updates.
There is no method to enhance low accuracy, you just get a point with some accuracy, if you are not interested in positions with low accuracy just skip this location and wait for a better one.
No perfect accuracy is available now, the accuracy is 100m for worse accuracy.
check android developers page for more information:
https://developer.android.com/training/location/receive-location-updates#location-request
Try this:
Set the accuracy level to ACCURACY_FINE
Set the highest power (to get best GPS signal)
Don’t request the altitude.
Set speedRequired to false
Set CostAllowed flag to true
Set BearingRequired to false
Set HorizontalAccuracy and VerticalAccuracy to HIGH
read more about these function, you will understand why.
Criteria tenM= new Criteria();
tenM.setAccuracy(Criteria.ACCURACY_FINE);
tenM.setPowerRequirement(Criteria.POWER_HIGH);
tenM.setAltitudeRequired(false);
tenM.setSpeedRequired(false);
tenM.setCostAllowed(true);
tenM.setBearingRequired(false);
tenM.setHorizontalAccuracy(Criteria.ACCURACY_HIGH);
tenM.setVerticalAccuracy(Criteria.ACCURACY_HIGH);
locationManager.requestLocationUpdates(1000 /*milliseconds*/, 1
/*1 meter*/,
tenM /*criteria*/, this /*context*/, null);
Thanks for your reply @KARAM JABER. Do you mean, i can't get location after 30 meter movement? and i just set displacement upper than 100 meter? I need update location after 30 meter in out door.
– Fahimeh Hashemian
Jan 20 at 8:47
you can get the location after 30m but the problem its not perfect accuracy, so after setting your smallest displacement, the location request will fire only if you surpassed that displacement on the next update, if not it will not. now it will keep checking, if the new position is with low accuracy, you should skip that one and wait for the more accurate one, but by that time you would have moved more than 30m and you will be waiting for the next one. Even big companies such as whatsapp and facebook when sending location is only accurate to 20m-30m minimum.
– KARAM JABER
Jan 20 at 9:36
Thanks @KARAM JABER. If i don't skip that low accuracy location, what happened? and How works applications like waze? The waze get location periodically and show my location in every millisecond!
– Fahimeh Hashemian
Jan 20 at 11:16
@FahimehHashemian you will get an undesired behavior, like what you are getting right now for 100m and not 30m. Check this edit for my answer, i got as accurate as 10m using.
– KARAM JABER
Jan 20 at 11:20
Finally @FahimehHashemian please setInterval not fastestInterval, setInterval is called faster than fastestInterval. The Irony
– KARAM JABER
Jan 20 at 11:28
|
show 3 more comments
LocationRequest.setSmallestDisplacement doesn't give you a better accuracy, it's just to avoid unnecessary updates.
There is no method to enhance low accuracy, you just get a point with some accuracy, if you are not interested in positions with low accuracy just skip this location and wait for a better one.
No perfect accuracy is available now, the accuracy is 100m for worse accuracy.
check android developers page for more information:
https://developer.android.com/training/location/receive-location-updates#location-request
Try this:
Set the accuracy level to ACCURACY_FINE
Set the highest power (to get best GPS signal)
Don’t request the altitude.
Set speedRequired to false
Set CostAllowed flag to true
Set BearingRequired to false
Set HorizontalAccuracy and VerticalAccuracy to HIGH
read more about these function, you will understand why.
Criteria tenM= new Criteria();
tenM.setAccuracy(Criteria.ACCURACY_FINE);
tenM.setPowerRequirement(Criteria.POWER_HIGH);
tenM.setAltitudeRequired(false);
tenM.setSpeedRequired(false);
tenM.setCostAllowed(true);
tenM.setBearingRequired(false);
tenM.setHorizontalAccuracy(Criteria.ACCURACY_HIGH);
tenM.setVerticalAccuracy(Criteria.ACCURACY_HIGH);
locationManager.requestLocationUpdates(1000 /*milliseconds*/, 1
/*1 meter*/,
tenM /*criteria*/, this /*context*/, null);
LocationRequest.setSmallestDisplacement doesn't give you a better accuracy, it's just to avoid unnecessary updates.
There is no method to enhance low accuracy, you just get a point with some accuracy, if you are not interested in positions with low accuracy just skip this location and wait for a better one.
No perfect accuracy is available now, the accuracy is 100m for worse accuracy.
check android developers page for more information:
https://developer.android.com/training/location/receive-location-updates#location-request
Try this:
Set the accuracy level to ACCURACY_FINE
Set the highest power (to get best GPS signal)
Don’t request the altitude.
Set speedRequired to false
Set CostAllowed flag to true
Set BearingRequired to false
Set HorizontalAccuracy and VerticalAccuracy to HIGH
read more about these function, you will understand why.
Criteria tenM= new Criteria();
tenM.setAccuracy(Criteria.ACCURACY_FINE);
tenM.setPowerRequirement(Criteria.POWER_HIGH);
tenM.setAltitudeRequired(false);
tenM.setSpeedRequired(false);
tenM.setCostAllowed(true);
tenM.setBearingRequired(false);
tenM.setHorizontalAccuracy(Criteria.ACCURACY_HIGH);
tenM.setVerticalAccuracy(Criteria.ACCURACY_HIGH);
locationManager.requestLocationUpdates(1000 /*milliseconds*/, 1
/*1 meter*/,
tenM /*criteria*/, this /*context*/, null);
edited Jan 20 at 11:25
answered Jan 20 at 8:41
KARAM JABERKARAM JABER
53213
53213
Thanks for your reply @KARAM JABER. Do you mean, i can't get location after 30 meter movement? and i just set displacement upper than 100 meter? I need update location after 30 meter in out door.
– Fahimeh Hashemian
Jan 20 at 8:47
you can get the location after 30m but the problem its not perfect accuracy, so after setting your smallest displacement, the location request will fire only if you surpassed that displacement on the next update, if not it will not. now it will keep checking, if the new position is with low accuracy, you should skip that one and wait for the more accurate one, but by that time you would have moved more than 30m and you will be waiting for the next one. Even big companies such as whatsapp and facebook when sending location is only accurate to 20m-30m minimum.
– KARAM JABER
Jan 20 at 9:36
Thanks @KARAM JABER. If i don't skip that low accuracy location, what happened? and How works applications like waze? The waze get location periodically and show my location in every millisecond!
– Fahimeh Hashemian
Jan 20 at 11:16
@FahimehHashemian you will get an undesired behavior, like what you are getting right now for 100m and not 30m. Check this edit for my answer, i got as accurate as 10m using.
– KARAM JABER
Jan 20 at 11:20
Finally @FahimehHashemian please setInterval not fastestInterval, setInterval is called faster than fastestInterval. The Irony
– KARAM JABER
Jan 20 at 11:28
|
show 3 more comments
Thanks for your reply @KARAM JABER. Do you mean, i can't get location after 30 meter movement? and i just set displacement upper than 100 meter? I need update location after 30 meter in out door.
– Fahimeh Hashemian
Jan 20 at 8:47
you can get the location after 30m but the problem its not perfect accuracy, so after setting your smallest displacement, the location request will fire only if you surpassed that displacement on the next update, if not it will not. now it will keep checking, if the new position is with low accuracy, you should skip that one and wait for the more accurate one, but by that time you would have moved more than 30m and you will be waiting for the next one. Even big companies such as whatsapp and facebook when sending location is only accurate to 20m-30m minimum.
– KARAM JABER
Jan 20 at 9:36
Thanks @KARAM JABER. If i don't skip that low accuracy location, what happened? and How works applications like waze? The waze get location periodically and show my location in every millisecond!
– Fahimeh Hashemian
Jan 20 at 11:16
@FahimehHashemian you will get an undesired behavior, like what you are getting right now for 100m and not 30m. Check this edit for my answer, i got as accurate as 10m using.
– KARAM JABER
Jan 20 at 11:20
Finally @FahimehHashemian please setInterval not fastestInterval, setInterval is called faster than fastestInterval. The Irony
– KARAM JABER
Jan 20 at 11:28
Thanks for your reply @KARAM JABER. Do you mean, i can't get location after 30 meter movement? and i just set displacement upper than 100 meter? I need update location after 30 meter in out door.
– Fahimeh Hashemian
Jan 20 at 8:47
Thanks for your reply @KARAM JABER. Do you mean, i can't get location after 30 meter movement? and i just set displacement upper than 100 meter? I need update location after 30 meter in out door.
– Fahimeh Hashemian
Jan 20 at 8:47
you can get the location after 30m but the problem its not perfect accuracy, so after setting your smallest displacement, the location request will fire only if you surpassed that displacement on the next update, if not it will not. now it will keep checking, if the new position is with low accuracy, you should skip that one and wait for the more accurate one, but by that time you would have moved more than 30m and you will be waiting for the next one. Even big companies such as whatsapp and facebook when sending location is only accurate to 20m-30m minimum.
– KARAM JABER
Jan 20 at 9:36
you can get the location after 30m but the problem its not perfect accuracy, so after setting your smallest displacement, the location request will fire only if you surpassed that displacement on the next update, if not it will not. now it will keep checking, if the new position is with low accuracy, you should skip that one and wait for the more accurate one, but by that time you would have moved more than 30m and you will be waiting for the next one. Even big companies such as whatsapp and facebook when sending location is only accurate to 20m-30m minimum.
– KARAM JABER
Jan 20 at 9:36
Thanks @KARAM JABER. If i don't skip that low accuracy location, what happened? and How works applications like waze? The waze get location periodically and show my location in every millisecond!
– Fahimeh Hashemian
Jan 20 at 11:16
Thanks @KARAM JABER. If i don't skip that low accuracy location, what happened? and How works applications like waze? The waze get location periodically and show my location in every millisecond!
– Fahimeh Hashemian
Jan 20 at 11:16
@FahimehHashemian you will get an undesired behavior, like what you are getting right now for 100m and not 30m. Check this edit for my answer, i got as accurate as 10m using.
– KARAM JABER
Jan 20 at 11:20
@FahimehHashemian you will get an undesired behavior, like what you are getting right now for 100m and not 30m. Check this edit for my answer, i got as accurate as 10m using.
– KARAM JABER
Jan 20 at 11:20
Finally @FahimehHashemian please setInterval not fastestInterval, setInterval is called faster than fastestInterval. The Irony
– KARAM JABER
Jan 20 at 11:28
Finally @FahimehHashemian please setInterval not fastestInterval, setInterval is called faster than fastestInterval. The Irony
– KARAM JABER
Jan 20 at 11:28
|
show 3 more comments
That's because your location accuracy is above 30m (presumably much higher). So when you change your location by 100 m, you are still in the estimated location circle. You can get location accuracy to see if true, but anyway you don't have a better choice than get coordinates frequently and choose the one with most accuracy.
add a comment |
That's because your location accuracy is above 30m (presumably much higher). So when you change your location by 100 m, you are still in the estimated location circle. You can get location accuracy to see if true, but anyway you don't have a better choice than get coordinates frequently and choose the one with most accuracy.
add a comment |
That's because your location accuracy is above 30m (presumably much higher). So when you change your location by 100 m, you are still in the estimated location circle. You can get location accuracy to see if true, but anyway you don't have a better choice than get coordinates frequently and choose the one with most accuracy.
That's because your location accuracy is above 30m (presumably much higher). So when you change your location by 100 m, you are still in the estimated location circle. You can get location accuracy to see if true, but anyway you don't have a better choice than get coordinates frequently and choose the one with most accuracy.
edited 20 hours ago
answered yesterday
Ali HasAli Has
315
315
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%2f54274184%2ffused-location-provider-setsmallestdisplacement-not-working-in-specific-movement%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