Pick up position of the cell. GPS

1

I have an application, where I need to get the coordinates of where the cell phone is when I open the registration form and then when I register, to store the 2 locations. How do I get the location of my cell phone?

    
asked by anonymous 30.07.2014 / 17:55

1 answer

2

1. Set the non-manifest to use GPS:

   <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION">

2. Create a LocationManager

LocationManager gerenciadordeLugar = (LocationManager)   : getSystemService(Context.LOCATION_SERVICE);

3. Make sure the GPS is turned on.

4. Implement a Listener and get the coordinates:

LocationListener meuListener = new MeuListener();
locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER, 5000, 10, meuListener);

Full gist example

    
30.07.2014 / 18:50