Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP]Count number of good locations before showing Start button. #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mizutori
Copy link
Owner

This is a demo to show how we can count good locations before allowing user to track their locations.
Here is the step

1.

Add a varibale goodGpsCount to count the number of initial good locations.
goodGpsCount

2.

In onLocationUpdate, after filtering the new location, if it passes the filter, count up goodGpsCount.
If goodGpsCount becomes more than or equal to 3, send broadcast to MainActivity.
https://github.com/mizutori/AndroidLocationStarterKitInKotlin/compare/secure-accuracy?expand=1#diff-73ccae8d1b2c89ef24ff25f60549f85125dc67d46c73e466ed9e0c19e2109129R66

3.

In MainActivity, make the startButton invisible in the beginning.
https://github.com/mizutori/AndroidLocationStarterKitInKotlin/compare/secure-accuracy?expand=1#diff-e4363ca693431b2287ffc5ce969d0abac1ee05f8729ff2d3a4efda2db4ca9df3R174

4.

When receiving the broadcast of goodGpsCount, make startButton visible.
https://github.com/mizutori/AndroidLocationStarterKitInKotlin/compare/secure-accuracy?expand=1#diff-e4363ca693431b2287ffc5ce969d0abac1ee05f8729ff2d3a4efda2db4ca9df3R144

Other Note

  • I changed the function filterAndAddLocation to filterLocation to return null (if location doesn't pass the filter) or location (if the location passes the filter). This is because I want to use this function even before the user presses startButton.
  • I removed Kalman filter to demonstrate this idea with maximum simplicity.

@mizutori mizutori changed the title Count number of good locations before showing Start button. [WIP]Count number of good locations before showing Start button. May 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant