我想在程序中通过点击一个按钮,以程序的方式来实现启动或禁用GPS,但是不能实现。
我要用的设备没有设置权限。
这是我使用的代码,错误出自哪呢?
private void gps()
{
Intent intent=new Intent("android.location.GPS_ENABLED_CHANGE");
Button gps = (Button)findViewById(R.id.gpsButton);
if(isGPSon())
{
intent.putExtra("enabled", true);
gps.setText(R.string.f2_gps_deact);
}
else
{
intent.putExtra("enabled", false);
gps.setText(R.string.f2_gps_act);
}
sendBroadcast(intent);