AndroidLocationStarterKit icon indicating copy to clipboard operation
AndroidLocationStarterKit copied to clipboard

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

Open mizutori opened this issue 2 years ago • 0 comments

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 avatar May 14 '22 07:05 mizutori