privatevoid turnGPSOn(){String provider = android.provider.Settings.Secure.getString(
getContentResolver(),
android.provider.Settings.Secure.LOCATION_PROVIDERS_ALLOWED);if(!provider.contains("gps")){// if gps is disabledfinalIntent poke =newIntent();
poke.setClassName("com.android.settings","com.android.settings.widget.SettingsAppWidgetProvider");
poke.addCategory(Intent.CATEGORY_ALTERNATIVE);
poke.setData(Uri.parse("3"));
sendBroadcast(poke);}}
上面代码在Android5.0上好像不能用。不知道哪个大神,知道如何在Android5.0上强制开关GPS啊。