Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started