I have a class named GPSSampleLocation
There is a function to turn on gps and based on that getting location
here gpsEnabled will be true but in my phone when I request for gps the GPS icon on above in my PHONE will be blinking ... but it is not blinking also... and I am not getting data
public void getGPSLocation() {
LocationManager mlocManager = (LocationManager) GPSSampleLocation.this
.getSystemService(Context.LOCATION_SERVICE);
boolean gpsEnabled = mlocManager
.isProviderEnabled(LocationManager.GPS_PROVIDER);
if (!gpsEnabled) {
String provider = Settings.Secure.getString(
getContentResolver(),
Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
if (!provider.contains("gps")) { // if gps is disabled
final Intent poke = new Intent();
poke.setClassName("com.android.settings",
"com.android.settings.widget.SettingsAppWidgetProvider");
poke.addCategory(Intent.CATEGORY_ALTERNATIVE);
poke.setData(Uri.parse("3"));
sendBroadcast(poke);
}
}
gpsEnabled = mlocManager
.isProviderEnabled(LocationManager.GPS_PROVIDER);
System.out.println("GPS ENALBLE" + gpsEnabled);
if (gpsEnabled) {
mlocManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER, 0, 0,
GPSSampleLocation.this);
}
}
I have also used these permissions :
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET"/>