I got the Latitude and longitude values in Emulator using Telnet.(i.e) GPS.
I have a doubt (i.e) without google map can we able to get the current location using the latitude and longitude.
I got the Latitude and longitude values in Emulator using Telnet.(i.e) GPS.
I have a doubt (i.e) without google map can we able to get the current location using the latitude and longitude.
You can fetch the current location using GPS and Google map both. If you want to fetch location through Google map then plz show this tutorial. And you can see this previous asked question.
If you want to fetch location without Google map then you can be use location manager.
To do this, we need to add the fallowing code in the OnCreate method:
/* Use the LocationManager class to obtain GPS locations */
LocationManager mlocManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
LocationListener mlocListener = new MyLocationListener();
mlocManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 0, 0, mlocListener);
In the custom class MyLocationListener using implements the interface LocationListener.
We will add our own personal Location listener, so we can override some of the functions to do what we want. In our case we will just print a message to the screen in the fallowing cases:
onLocationChanged ( Location Update )
onProviderDisabled ( GPS Off )
onProviderEnabled (GPS On )
And add another mandatory method, which will do nothing.
onStatusChanged (We are not adding nothing here).
After that give the permission in AndroidManifest.xml file:
android:name="android.permission.ACCESS_FINE_LOCATION"
You can get latitude and longitude by this code
GPS_Location mGPS = new GPS_Location(MyApplication.getAppContext());
if (mGPS.canGetLocation) {
mLat = mGPS.getLatitude();
mLong = mGPS.getLongitude();
} else {
System.out.println("cannot find");
}
you must add the gps permissions and other permissions to your app