vergil corleone
vergil corleone

Reputation: 1101

What kind of data does the data type `Location` store?

I am making a GPS app for android. I need to know the location of the user. What kind of data does location store in this :

Location location = locationManager.getLastKnownLocation(provider);

I mean does it store the co-ordinates or the city name etc?

Upvotes: 1

Views: 2461

Answers (1)

Ribose
Ribose

Reputation: 2233

As per Location, it contains:

A data class representing a geographic location.

A location can consist of a latitude, longitude, timestamp, and other information such as bearing, altitude and velocity.

All locations generated by the LocationManager are guaranteed to have a valid latitude, longitude, and timestamp (both UTC time and elapsed real-time since boot), all other parameters are optional.

So yes, you can use methods from that page which the device knows.

See the Geocoder class on how to look up the city.

Upvotes: 2

Related Questions