give permissions
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
LocationManager locationmgr =
(LocationManager)getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria();
/*criteria.setAccuracy(Criteria.ACCURACY_FINE);
criteria.setAltitudeRequired(false);
criteria.setBearingRequired(false);
criteria.setCostAllowed(true);
criteria.setPowerRequirement(Criteria.POWER_LOW); */
String provider = locationmgr.getBestProvider(criteria, false);
// Location location = locationmgr.getLastKnownLocation(provider);
//LatLng userLocation = new
LatLng(location.getLatitude(),location.getLongitude())
locationmgr.requestLocationUpdates(provider, 100, dis,new MyListener());
location = locationmgr.getLastKnownLocation(provider);
if(location !=null)
{
lon = location.getLongitude();
lat = location.getLatitude();
}
class MyListener implements LocationListener
{
@Override
public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
// lat = location.getLatitude();
// lon = location.getLongitude();
Log.i("getLatitude", ""+location.getLatitude());
Log.i("getLongitude", ""+location.getLongitude());
}
@Override
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}
@Override
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}
@Override
public void onStatusChanged(String provider, int status, Bundle
extras) {
// TODO Auto-generated method stub
}
}
>>
>
--
Thanks & Regards,
--------------------------
Manish Shrivas
ADI Soft Tech (P) Ltd.
54, Anand Nagar, Near Devi Ahilya Hospital,
Chitawad Road ,
INDORE
Mob no. 9907631333
*------------------------*
*[email protected]*
http://www.adisoftin.com/
--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.