Replies: 2 comments 8 replies
-
@qiarie looks great! Some questions below: a. Is the background worker in (3) always running or do we call it on demand when we want to get the gps, if always, is that so we do not need to wait for the gps to sync when we want to collect it? |
Beta Was this translation helpful? Give feedback.
-
How to store the collected GPS coordinates.
When to collect the GPS coordinates.
|
Beta Was this translation helpful? Give feedback.
-
Background
There is a request to have the ability to capture the geographical location where a questionnaire was filled. The location information will be used to validate activities by agents in the field. The location capture should be done in the background without the need for user input.
The feature to collect the location on questionnaire submission should be configurable. For applications that have this feature enabled, location services must be enabled and permissions granted for the feature to work.
Proposed Implementations
Configure Google Play services dependency in quest's
build.gradle
Request for
ACCESS_FINE_LOCATION
andACCESS_COARSE_LOCATION
permissions inAndroidManifest.xml
Add a config parameter to
ApplicationConfiguration
to control whether location information should be captured on questionnaire submissionBefore launching a questionnaire, check the application config parameter
logQuestionnaireLocation
is set totrue
.If location logging is set, check whether the application has
ACCESS_FINE_LOCATION
andACCESS_COARSE_LOCATION
permissions and prompt the user to grant the permissions if not granted.Options on how to pick the current location
a. Approach 1 - Use
FusedLocationProviderClient
(preferred)Create and instantiate an instance of the Fused Location Provider Client
On questionnaire submission (*), get the current or last location using the
fusedLocationClient
.From Android documentation:
b. Approach 2 - Implement a background location service worker
In
QuestionnaireActivity.handleQuestionnaireSubmit()
, check that the application config parameterlogQuestionnaireLocation
is set totrue
and the application hasACCESS_FINE_LOCATION
andACCESS_COARSE_LOCATION
permissions.Add the geo-coordinates items - longitude, latitude & altitude - to the QuestionnaireResponse.
Add a util method to create a location resource capturing the details listed below.
Location.identifier
- same id as that assigned to the Group resource in the questionnaireLocation.position
- absolute geographic locationlongitude
- [required]latitude
- [required]altitude
- [optional]The location resource above will be added to the
QuestionnaireResponse
'scontained
attribute.Notes:
References
Beta Was this translation helpful? Give feedback.
All reactions