/*** Determine if the GPS is on, GPS or aGPS to open a thought is open *@paramContext *@returnTrue indicates that the open*/ Public Static Final BooleanIsgpsopen (Finalcontext Context) {Locationmanager Locationmanager=(Locationmanager) Context.getsystemservice (Context.location_service); //GPS satellite positioning, positioning level can be accurate to the street (through 24 satellite positioning, in the outdoor and open location accurate, fast) BooleanGPS =locationmanager.isproviderenabled (Locationmanager.gps_provider); //a location determined by the WLAN or mobile network (3G/2G), also known as AGPS, assists with GPS positioning. Mainly used in indoor or in the shelter (complex or dense deep forest, etc.) dense place positioning) BooleanNetwork =locationmanager.isproviderenabled (Locationmanager.network_provider); if(GPS | |Network) { return true; } return false; } /*** Go to set up GPS interface *@paramContext*/ Public Static Final voidGotosetgps (Context context) {Intent Intent=NewIntent (); Intent.setaction (settings.action_location_source_settings); Intent.setflags (Intent.flag_activity_new_task); Try{context.startactivity (intent); } Catch(Activitynotfoundexception ex) {//The Android SDK Doc says that's the location settings activity//May is not found. In this case show the general settings. //General Settings Activityintent.setaction (settings.action_settings); Context.startactivity (Intent); } }
Determine if GPS is turned on & go to set GPS interface