//自动开启GPS方法-Private void toggle GPS(){ intent GPS intent = new intent();GPS intent . set class name(& quot;com . Android . settings & quot;,& quotcom . Android . settings . widget . settings appwidgetprovider & quot;);GPS intent . add category(& quot;Android . intent . category . alternative & quot;);GPS intent . setdata(uri . parse(& quot;自定义:3 & quot));请尝试{ pending intent . get broadcast(near activity . this,0,gpsIntent,0)。send();} catch(canceled exception e){ e . printstacktrace();} }//自动开启GPS方法2.2后,可以使用private void opengpsettings(){//获取GPS的当前状态(开启或关闭状态)。boolean GPS enabled = settings . secure . islocationproviderenabled(get content resolver()、location manager . GPS _ provider);If(gpsEnabled) {//关闭GPS settings . secure . setlocationprovided enabled(get content resolver(),locationmanager.gps _ provider,false);} else {//Open GPS settings . secure . setlocationprovidenabled(get content resolver(),locationmanager.gps _ provider,true);}}查看原帖> & gt