Is it possible to programmatically enable wifi on Android 10 devices?
Asked Answered
R

3

5

Since setWifiEnabled is deprecated on Android 10, how does one programatically enable wifi on Android 10 devices?

Is it not possible to programmatically enable wifi at all on Android 10+ (SDK 29) ?

Ran answered 24/9, 2019 at 8:16 Comment(2)
Possible duplicate of Turning on wifi using WifiManager stops to work on Android 10Officialese
I guess https://mcmap.net/q/832213/-turning-on-wifi-using-wifimanager-stops-to-work-on-android-10 might help you with the WiFi toggling issue.Understrapper
M
12

No, This is not possible to enable or disable Wi-Fi programmatically from Android-10 API level 29 [Until google provides an alternative solution].

For applications targeting Build.VERSION_CODES.Q or above, this API will always return false and will have no effect.

If apps are targeting an older SDK ( Build.VERSION_CODES.P or below), they can continue to use this API.

There is an issue 128554616 which already has been created in google issuetracker forum. You can see there for any updated info.

Methinks answered 24/9, 2019 at 8:45 Comment(4)
Ah, the API itself is take away. This turned out more interesting than I thought :-)Ran
I have updated my answer with an issuetracker which is already created in google forum. hope you can find more info from thers. Happy Coding.Methinks
Google answered with a "Won't Fix (Intended behavior)". This is worse each android update.Kip
I am using the val wifiManager = context.getSystemService(Context.WIFI_SERVICE) as WifiManager wifiManager.isWifiEnabled = true FOR ENABLING THE WIFI in android 8 BUT its not working. Any other optionGangue
H
6

Now in android 10 you can do like this

Intent panelIntent = new Intent(Settings.Panel.ACTION_INTERNET_CONNECTIVITY);
startActivityForResult(panelIntent);

ACTION_INTERNET_CONNECTIVITY Shows settings related to internet connectivity, such as Airplane mode, Wi-Fi, and Mobile Data.

ACTION_WIFI Shows Wi-Fi settings, but not the other connectivity settings. This is useful for apps that need a Wi-Fi connection to perform large uploads or downloads.

ACTION_NFC Shows all settings related to near-field communication (NFC).

ACTION_VOLUME Shows volume settings for all audio streams.

Heins answered 20/3, 2020 at 11:37 Comment(1)
This doesn't answer "How to programaticaly enable wifi on 10+", but does give the nearest available option targeting SDK 29.Baten
H
-1

Yes it is! Google is giving the answer pretty clearly:

If apps are targeting an older SDK ( Build.VERSION_CODES.P or below), they can continue to use this API.

Change your API to 28 and it works great. Or if you need a solution for Apps like Tasker or Automate see my post here: https://mcmap.net/q/832213/-turning-on-wifi-using-wifimanager-stops-to-work-on-android-10

Hospitality answered 26/11, 2020 at 13:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.