[Java]
<SPAN style = "FONT-FAMILY: Arial, Helvetica, sans-serif"> <SPAN style = "FONT-SIZE: 18px">
</SPAN>
[Java]
<SPAN style = "FONT-FAMILY: Arial, Helvetica, sans-serif"> <SPAN style = "FONT-SIZE: 18px"> during the project, A problem occurs: when you experience a function, you need to check whether the user has enabled the GPS positioning service. If not, you need to enter the positioning service setting interface. </SPAN>
During the project process today, a problem occurs: when you experience a function, you need to check whether the GPS positioning service has been enabled. If not, you need to enter the positioning service setting interface.
The following code is directly pasted:
The following code is placed in the Button listening event, and only the important code is pasted.
[Java]
<SPAN style = "FONT-SIZE: 18px"> LocationManager alm = (LocationManager) getSystemService (Context. LOCATION_SERVICE );
If (alm. isProviderEnabled (android. location. LocationManager. GPS_PROVIDER )){
Toast. makeText (getApplicationContext (), "GPS enabled", Toast. LENGTH_SHORT). show ();
Return;
}
StartActivity (new Intent ("android. settings. LOCATION_SOURCE_SETTINGS"); </SPAN>
LocationManager alm = (LocationManager) getSystemService (Context. LOCATION_SERVICE );
If (alm. isProviderEnabled (android. location. LocationManager. GPS_PROVIDER )){
Toast. makeText (getApplicationContext (), "GPS enabled", Toast. LENGTH_SHORT). show ();
Return;
}
StartActivity (new Intent ("android. settings. LOCATION_SOURCE_SETTINGS "));
After searching on the Internet, there are many other system settings that can be opened. The following article describes how to enable these settings.