I think  this code will help you.

import android.app.IntentService;
import android.content.Intent;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;

public class LocationFinderService extends IntentService implements
LocationListener{
private LocationFilter lp=null;
private LocationManager locationManager=null;
private Location location=null;
public LocationFinderService(){
super("My Thread");
}
public void onHandleIntent(Intent intent){
while (true){
lp.putLocation(this.location);
}
}
public void findLocation(){
this.locationManager=(LocationManager)getSystemService(LOCATION_SERVICE);
this.locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
10*1000, 10,this );
this.locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,10*1000,10,this);
}
public void onLocationChanged(Location location) {
if(location!=null){
this.location=location;
this.locationManager.removeUpdates(this);
}
 }
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
 }
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
 }
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub
 }
}


On Tue, May 29, 2012 at 11:38 AM, yogendra G <[email protected]> wrote:

> Hi All,
>
> I need to display current longitude and latitude where am staying at
> present location and my code works fine for android 2.3 below os but not
> for android 2.3 version.
> So,please help me out by giving some sample code or links where the code
> works for android 2.3.x.x versions.
>
> Thanks in Advance.
>
> Br,
> Yogi
>
> --
> 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 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

Reply via email to