Answered step by step
Verified Expert Solution
Link Copied!

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(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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Autonomous Database In Enterprise Architecture

Authors: Bal Mukund Sharma, Krishnakumar KM, Rashmi Panda

1st Edition

1801072248, 978-1801072243

More Books

Students also viewed these Databases questions

Question

74 Motivation concepts and applications.

Answered: 1 week ago