Android locations are expressed in terms of latitude and longitude coordinates. The default format is degrees. The Location object can also be used to store a time-stamp and other information such as speed and distance traveled.
Although obtaining a device's last known location does not always yield the most accurate information, it is often the first reading that we may want. It is fast, simple to employ, and makes a good introduction to the LocationManager.
Start a new Android project in Eclipse and provide the following permission to the manifest file as a child of the root node:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Use the TextView provided in the
main.xml
file and give it a resource ID:android:id="@+id/text_view"
Declare a TextView as a class-wide field in the Java activity code:
TextView textView;
Then, find it in the usual way, from within the
onCreate()
method:textView = (TextView) findViewById...