Determine if GPS is turned on & go to set GPS interface

Source: Internet
Author: User

/*** 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.