Need to configure permissions
<android:name= "Android.permission.ACCESS_WIFI_STATE"/> <android:name= "Android.permission.ACCESS_FINE_LOCATION"/>
Determine the WiFi and GPS status of Android
Private voidCheckwifiandgpsstatus () {Booleanresult =true; /*get Wifimanager and Locationmanager*/Wifimanager Wmanager=(Wifimanager) Getsystemservice (Context.wifi_service); Locationmanager Lmanager=(Locationmanager) Getsystemservice (Context.location_service); /*confirm that the WiFi service is turned off and not in the open operation*/ if(!wmanager.iswifienabled ()&& wmanager.getwifistate ()! =wifimanager.wifi_state_enabling) {Tv01.settext ("WiFi Status: Not Started"); Result=false; } Else{Tv01.settext ("WiFi Status: Started"); } /*Verify that the GPS is turned on*/ if(!lmanager.isproviderenabled (Locationmanager.gps_provider)|| !Lmanager. isproviderenabled (Locationmanager.network_provider)) {Tv02.settext ("GPS Status: Not Started"); Result=false; } Else{Tv02.settext ("GPS Status: Started"); } if(Result) {mbutton03.setenabled (true); } Else{mbutton03.setenabled (false); } }
Skip to WiFi Settings screen
New Intent (Android.provider.Settings.ACTION_WIFI_SETTINGS); 0);
Jump to the GPS settings screen
New Intent (Android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS); 0);
Determine the WiFi and GPS status of Android, and guide users to turn on GPS and WiFi settings