Ich habe eine Klasse namens GPSSampleLocation
Es gibt eine Funktion zum Einschalten von GPS und zum Abrufen des Standorts auf der Grundlage dieser Funktion
hier gpsEnabled wird wahr sein, aber in meinem Telefon, wenn ich für gps das GPS-Symbol auf oben in meinem PHONE anfordern wird blinken ... aber es ist nicht blinken auch ... und ich bin nicht bekommen Daten
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);
}
}
Ich habe diese Genehmigungen auch genutzt:
<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"/>