Android 8.0无法打开wifi开关

时间:2018-11-11 09:48:22

标签: android

当我打开wifi开关时,该开关将自动关闭。 我不知道是什么原因造成的。

这是日志

12-31 19:02:10.566 D/WifiService( 2139): setWifiEnabled: true pid=3201, uid=1000, package=com.android.tv.settings
12-31 19:02:10.629 D/WificondControl( 2139): wifiLoadDriver() in wificond
12-31 19:02:10.649 I/wificond( 1921): user don't need load driver
12-31 19:02:10.649 I/wificond( 1921): wifiLoadDriver flag=1
12-31 19:02:10.709 E/android.hardware.wifi@1.0-service( 1889): Failed to initialize legacy hal function table
12-31 19:02:10.709 E/android.hardware.wifi@1.0-service( 1889): Failed to initialize legacy HAL: NOT_SUPPORTED
12-31 19:02:10.713 I/android.hardware.wifi@1.0-service( 1889): Wifi HAL started
12-31 19:02:10.733 E/HalDeviceManager( 2139): IWifiEventCallback.onFailure: 4 ()
12-31 19:02:10.733 E/HalDeviceManager( 2139): Cannot start IWifi: 4 ()
12-31 19:02:10.743 E/WifiNative-wlan0( 2139): Failed to start HAL for client mode
12-31 19:02:10.810 D/WificondControl( 2139): tearing down interfaces in wificond
12-31 19:02:10.813 I/WifiVendorHal( 2139): Vendor Hal stopped
12-31 19:02:10.813 D/WificondControl( 2139): wifiLoadDriver() in wificond
12-31 19:02:10.815 I/wificond( 1921): user don't need load driver
12-31 19:02:10.815 I/wificond( 1921): wifiLoadDriver flag=1
12-31 19:02:10.819 E/android.hardware.wifi@1.0-service( 1889): Failed to initialize legacy hal function table
12-31 19:02:10.819 E/android.hardware.wifi@1.0-service( 1889): Failed to initialize legacy HAL: NOT_SUPPORTED
12-31 19:02:10.819 I/android.hardware.wifi@1.0-service( 1889): Wifi HAL started
12-31 19:02:10.820 E/HalDeviceManager( 2139): Cannot start IWifi: 4 ()
12-31 19:02:10.820 E/HalDeviceManager( 2139): IWifiEventCallback.onFailure: 4 ()
12-31 19:02:10.821 E/WifiNative-wlan0( 2139): Failed to start HAL for client mode
12-31 19:02:10.822 D/WificondControl( 2139): tearing down interfaces in wificond
12-31 19:02:10.825 I/WifiVendorHal( 2139): Vendor Hal stopped

1 个答案:

答案 0 :(得分:0)

确保您具有此权限

<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>

并每次创建wifiManager

WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
wifiManager.setWifiEnabled(true);