【发布时间】:2011-12-22 07:39:55
【问题描述】:
我在我的应用程序中使用 GPS,我想以编程方式打开和关闭 GPS 以节省电量我该怎么做 :(
这是为了关机,我需要开机
private void turnGPSOnOff(){
String provider = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
if(!provider.contains("gps")){
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);
//Toast.makeText(this, "Your GPS is Enabled",Toast.LENGTH_SHORT).show();
}
}
【问题讨论】:
-
你不考虑接受答案
标签: android google-maps-api-3 gps