Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Android): Open the Wifi settings panel on Android 10 and above. #319

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion android/src/main/java/com/reactlibrary/rnwifi/RNWifiModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,22 @@ public void isEnabled(final Promise promise) {
*/
@ReactMethod
public void setEnabled(final boolean enabled) {
wifi.setWifiEnabled(enabled);
if (isAndroidTenOrLater()) {
openWifiSettings();
} else {
wifi.setWifiEnabled(enabled);
}
}

/**
* Use this to open a wifi settings panel.
* For Android Q and above.
*/
@ReactMethod
public void openWifiSettings() {
Intent intent = new Intent(Settings.Panel.ACTION_WIFI);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.context.startActivity(intent);
}

/**
Expand Down