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(10000)
.setFastestIntervalMillis(5000)
.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
.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(5000)
.setPriority(PRIORITY_HIGH_ACCURACY)
.setMinUpdateIntervalMillis(100)
//.setMinUpdateDistanceMeters(1000F)
.build()
My app works if the user chooses Precise location(as 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(5000)
.setPriority(PRIORITY_BALANCED_POWER_ACCURACY)
.setMinUpdateIntervalMillis(100)
.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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!