tags:

views:

170

answers:

1

i am implementing gps provider getting langitude and longitude from device i am already get the information in device i can implemented network provider that is the problem how can implemented using network provider

+1  A: 

The code is basically the same. Obtain a provider (gps, network, etc.), call getLastKnownLocation. Additionally you can request location updates for this provider. But you can't test this using the emulator, you'll need a phone.

LocationManager manager = (LocationManager) Context.getSystemService(Context.LOCATION_SERVICE);
manager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);

// additionally (you have to implement LocationListener)
manager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0.0f, new LocationListener() ...)
Nikola Smiljanić
thank you very much