Skip to content

add option for GPS mode that probably saves on battery #98

@biblicabeebli

Description

@biblicabeebli

@enwq and their fork of the android app implemented a (much) more modern option than we currently use, this is an extract from #89

--

Regarding our app, we host it in our organization repo so you won't be able to see the changes we made. Specifically we modified the GPS listener. Beiwe is using GPS_PROVIDER plus a duty cycle to sense locations. However we prefer a more continuous sensing scheme. At the same time we don't want it to consume too much power.

So we use the FUSED_PROVIDER (added in Android 12) with QUALITY_BALANCED_POWER_ACCURACY as the location provider and configured the GPS OFF duration to 1. In this case it collects location data more continuously while mostly relying on Wi-Fi and cellular signals. Location accuracy is usually 10-100 meters which is okay for our study since we don't really need location samples with GPS-level accuracy.

I believe this FUSED_PROVIDER is mostly the same as Fused Location Provider API from Google Play Services, which can be used for devices earlier than Android 12. Looks like Google decided to add some contents from this API to the native Android locationManager for Android 12. In our study we simply limit participants to those running Android 12 and above.

--

I would be very interested to see that code, as you can probably tell it has been a while since the android app had a tech update, and that sounds like it would save on battery life.

Sure here's the code.

        // Create location request
        val locationRequestBuilder = LocationRequest.Builder(10000)
        locationRequestBuilder.setQuality(QUALITY_BALANCED_POWER_ACCURACY)
        locationRequestBuilder.setMinUpdateIntervalMillis(1000)
        val locationRequest = locationRequestBuilder.build()

        // Initialize a custom executor
        val executor = Executors.newSingleThreadExecutor()

        if (finePermissible && coarsePermissible && locationManager.hasProvider("fused")){
            locationManager.requestLocationUpdates(LocationManager.FUSED_PROVIDER,locationRequest,executor,this)
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions