Question: I m making a program in Android Studio with Kotlin, where I need to get the user s updated location. According to the documentation, this
Im making a program in Android Studio with Kotlin, where I need to get the users updated location.
According to the documentation, this is how one should make a LocationRequest:
val locationRequest LocationRequest.Builder
setIntervalMillis
setFastestIntervalMillis
setPriorityLocationRequestPRIORITYHIGHACCURACY
build
However, Android Studio gives me an error if I dont include a number in the parentheses after Builder. So mine has to look like this in order for there to not be an error:
locationRequest LocationRequest.Builder
setPriorityPRIORITYHIGHACCURACY
setMinUpdateIntervalMillis
setMinUpdateDistanceMetersF
build
My app works if the user chooses Precise locationas in the code above but the problem occurs when Im trying to make a LocationRequest for Approximate location with the code below:
locationRequest LocationRequest.Builder
setPriorityPRIORITYBALANCEDPOWERACCURACY
setMinUpdateIntervalMillis
build
When I change the emulators location in Android Studio, the location which is displayed on the app screen using composable functions is not updated. This only happens if the user chooses Approximate location
So my problem is how do I get updates on the users location if the user chooses Approximate location
I would like to know what Im doing wrong.
I would also like to know why Android Studio tells me I need an argument inside Builder when the documentation doesnt include an argument there.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
