我用我的應用GPS,我想開啓GPS和關閉編程以節省電能我怎麼能做到這一點 :(android在2.2中以編程方式打開和關閉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();
}
}
Ÿ沒有想到abbt accpting的答案 – drooooooid 2011-12-22 09:07:22
可能重複[啓用GPS編程喜歡塔斯克(http://stackoverflow.com/questions/4721449/enable-gps-programatically-like-tasker) – 2011-12-22 09:29:31