Skip to content

Commit

Permalink
fix(Android): Open the Wifi settings panel on Android 10 and above. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
MagnasiePro committed Oct 27, 2023
1 parent f572a81 commit bd89902
Showing 1 changed file with 16 additions and 1 deletion.
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

0 comments on commit bd89902

Please sign in to comment.