sonicuser
شنبه 11 اردیبهشت 1395, 10:23 صبح
سلام دوستان
کسی کدی برای روشن کردن gps داره
من این کد رو پیدا کردم اما من میخام سنسور gps روشن بشه ن قسمت wifi gps
public void turnGPSOn() {
try {
Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE");
intent.putExtra("enabled", true);
this.sendBroadcast(intent);
String provider = Settings.Secure.getString(this.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.SettingsAppWidgetProvi der");
poke.addCategory(Intent.CATEGORY_ALTERNATIVE);
poke.setData(Uri.parse("2"));
this.sendBroadcast(poke);
}
} catch (Exception e) {
}
// getLocationGPS();
}
کسی کدی برای روشن کردن gps داره
من این کد رو پیدا کردم اما من میخام سنسور gps روشن بشه ن قسمت wifi gps
public void turnGPSOn() {
try {
Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE");
intent.putExtra("enabled", true);
this.sendBroadcast(intent);
String provider = Settings.Secure.getString(this.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.SettingsAppWidgetProvi der");
poke.addCategory(Intent.CATEGORY_ALTERNATIVE);
poke.setData(Uri.parse("2"));
this.sendBroadcast(poke);
}
} catch (Exception e) {
}
// getLocationGPS();
}