Skip to content

Count number of good locations before showing Start button. #6

Open
mizutori wants to merge 1 commit into
masterfrom
test
Open

Count number of good locations before showing Start button. #6
mizutori wants to merge 1 commit into
masterfrom
test

Conversation

@mizutori
Copy link
Copy Markdown
Owner

@mizutori mizutori commented May 14, 2022

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.
https://github.com/mizutori/AndroidLocationStarterKit/pull/6/files#diff-93d98e0953cbfe5d527fa9991537cb545dd5dbe6d4b4dfc65992105478fc2077R59

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/AndroidLocationStarterKit/pull/6/files#diff-93d98e0953cbfe5d527fa9991537cb545dd5dbe6d4b4dfc65992105478fc2077R286

3.

In MainActivity, make the startButton invisible in the beginning.
https://github.com/mizutori/AndroidLocationStarterKit/pull/6/files#diff-40c5403e3f39c3d55b4e8d6447d31e6378231d346d6d955214bcc10bc9c3aa31R198

4.

When receiving the broadcast of goodGpsCount, make startButton visible.
https://github.com/mizutori/AndroidLocationStarterKit/pull/6/files#diff-40c5403e3f39c3d55b4e8d6447d31e6378231d346d6d955214bcc10bc9c3aa31R147

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 Test update. This app at least runs. 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