android - Ask user to turn on Wi-Fi -


i have app needs know user location.

when need access location, this:

final alertdialog.builder builder = new alertdialog.builder(                         mapscreen.this); builder.settitle("myappname"); builder.setmessage("the location service off. want turn on?");                 builder.setpositivebutton("enable location",                         new dialoginterface.onclicklistener() {                             @override                             public void onclick(                                     final dialoginterface dialoginterface,                                     final int i) {                                 startactivity(new intent(                                         android.provider.settings.action_location_source_settings));                             }                         }); builder.setnegativebutton("continue without location", null); builder.create().show(); 

however, gps gives me info isn't precise enough. wi-fi gives me enough precission, want ask user turn on wi-fi same way ask them turn on location. not want turn on, want user notified it, , manually enable it.

is there intent bring wifi menu user?

following intent shows wireless settings such wi-fi, bluetooth , mobile networks:

startactivity(new intent(settings.action_wireless_settings)); 

for complete list of settings: https://developer.android.com/reference/android/provider/settings.html

for documentation on startactivity method: https://developer.android.com/reference/android/app/activity.html#startactivity(android.content.intent)

(keep in mind startactivity throw , forget, if want capture response of user did out there instead call startactivityforresult, not needed in case)


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -