1
I have an application, where I need to get the coordinates of where the phone is time I open the registration form and then when I register, to store the 2 locations. How do I get the location of the phone?
1
I have an application, where I need to get the coordinates of where the phone is time I open the registration form and then when I register, to store the 2 locations. How do I get the location of the phone?
2
1. Define in the manifest that will use the GPS:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION">
2. Create a Locationmanager
LocationManager gerenciadordeLugar = (LocationManager) : getSystemService(Context.LOCATION_SERVICE);
3. Check that the GPS is on.
4. Implement a Listener and get the coordinates:
LocationListener meuListener = new MeuListener();
locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER, 5000, 10, meuListener);
Browser other questions tagged android
You are not signed in. Login or sign up in order to post.
In step 3, check if the GPS is on, I have to do this manually?
– meisterx7
Yeah, and if you look at the code I posted on gist you will see that this code in that part:
flag = displayGpsStatus();
– Mansueli
And this Locationlistener is imported from android.Location or com.google.android.gms.Location?
– meisterx7
And what will become of the Istener?
– meisterx7
@meisterx7
import android.location.LocationListener;
. Please see gist. It’s all there.– Mansueli
Friend, please.. I am studying Android Studio and GPS, but this gist code this OFF !?! Please have another place for me to consult and see how it works.. I really wanted to learn this! THANK YOU!
– Camila Yamamoto
@Camilayamamoto changed my name on github a little while ago, I forgot that this was there. Thanks for telling ( tidy link)
– Mansueli