Im new to android development and i understand the android activity life cycle. Please see the following code.
public class MyTest extends Activity{
LocationClient is the new way of getting GPS. Watch video for complete details on the recent update.
Note that the LocationManager way of doing things is buggy, since there is need to add a lot of code for GPS and NETWORK provider. The new way (internal to Google referred to as the Fused Location Provider) works with sensors to reduce battery consumption big time. Also reduces the need for complex API's and stage wise selection of the best provider. Its just 2-3 lines of code and you are done.
With many Samsung phones (Y model including) though there is a specific issue that most of the times they don't return location at all. So you need to kick start that phone to return the GPS. To do that you can use
HomeScreen.getLocationManager().requestLocationUpdates(
LocationManager.NETWORK_PROVIDER, 0, 0, new LocationListener() {
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
@Override
public void onProviderEnabled(String provider) {
}
@Override
public void onProviderDisabled(String provider) {
}
@Override
public void onLocationChanged(final Location location) {
}
});
And then call your locationClient.getLastLocation
api. As in put the code above, just before your LocationClient.getLastLocation or LocationManager.getLastKnownLocation call.
Mind you Samsung is the highly customized android open source product. Google cannot respond to samsung related bugs, and Samsung does not have any android developer related support.
Edit : Watch the video, trust me, without knowing what LocationClient gives you, you wont appreciate the change. You will also learn about GeoFenceing.