Android Wifi Settings within app(Kiosk-sh app)

2019-05-27 10:49发布

问题:

So I am writing a app that runs on Android 4.4.2. I need to make my app be the only thing that is capable of running(Like what many call kiosk mode). The device manufacturer is removing the top menu bar and navigation bar so the user can't access anything but our app that is assigned to be the home screen.

The only issue is I need the user to be able to setup wifi networks, but do now want them to have access to any other settings of any kind.

Ideally I just want a wifi settings popup that occasionally comes up on other devices when you enable wifi.

Is there any way to achieve this without writing my own wifi configuration menu?

Thanks.

EDIT: To clarify, I have tried simple intents but they do not achieve what is needed. they result in something like this: http://g04.s.alicdn.com/kf/HT135ULFO0cXXagOFbXV/2503257/HT135ULFO0cXXagOFbXV.jpg Where the user will still have access other settings.

Ive used

startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));

startActivityForResult(new Intent(Settings.ACTION_WIFI_SETTINGS), 0);

I was hoping the second one would open a dialog and not the settings but it didn't work.

回答1:

The following should accomplish what you're after:

Intent intent = new Intent("com.android.net.wifi.SETUP_WIFI_NETWORK");
intent.setComponent(ComponentName.unflattenFromString("com.android.settings/com.android.settings.wifi.WifiSetupActivity"));
intent.addCategory("android.intent.category.DEFAULT");
startActivity(intent);

I came up with this after needing to do something very similar and hunting through the source of the Android Settings activities. As far as I can tell, there isn't a defined action to launch the wifi activity without all the other settings listed out, but we can get to it by assembling the intent manually.