Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "mWifiServiceMessenger == null" exception in LogCat imply?

When getting a WifiManager System Service like this

WifiManager mainWifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);

I have the following permissions in the Manifest file:

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

Eclipse LogCat logs an error

"mWifiServiceMessenger == null" [Tag: WifiManager]

Everything seems to work fine nevertheless. I do get an instance of WifiManager back. But the error is logged, also regardless of the Wifi state (enabled or disabled.

I would like to understand why this error is logged and what it does imply.

like image 786
sleidig Avatar asked Oct 31 '22 13:10

sleidig


2 Answers

This error occurs when the device has the WiFi turned off. If the device can't get the WIFI_SERVICE.

Anyway not all the devices throw this error.

In your case it is posible that you're trying to get the WiFi service and if not you're using the cellular data.

It is thrown by WifiManager:

E/WifiManager: mWifiServiceMessenger == null
like image 112
MarcGV Avatar answered Nov 15 '22 05:11

MarcGV


I had the same problem and I found the solution. You have to add CHANGE_WIFI_STATE permission in your manifest.

<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
like image 35
Johny Avatar answered Nov 15 '22 03:11

Johny