Note that there are some explanatory texts on larger screens.

plurals
  1. POWifi Enabling broadcast coming late
    primarykey
    data
    text
    <p>I've got a widget that I'm trying to use to enable/disable wifi, as well as display some additional info. I want to show a transitional hourglass icon while Wifi is enabling/disabling, so I'm listening for the android.net.wifi.WIFI_STATE_CHANGED intent.</p> <p>When that intent is caught I'm calling the widget's onUpdate function, and in that I have this block of code for changing the image displayed:</p> <pre><code>WifiManager wifiMan = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); WifiInfo wifiInfo = wifiMan.getConnectionInfo(); RemoteViews views = new RemoteViews("com.nickavv.cleanwidgets", R.layout.wifi_toggle_layout_large); supState = wifiInfo.getSupplicantState(); wifiState = wifiMan.getWifiState(); if(wifiState == WifiManager.WIFI_STATE_ENABLED) { //Show enabled image } else if(wifiState == WifiManager.WIFI_STATE_DISABLED){ //Show disabled image } else { //Show hourglass } </code></pre> <p>And here's my code for intercepting clicks and wifi state changes:</p> <pre><code>@Override public void onReceive(Context context, Intent intent) { super.onReceive(context, intent); if (intent.getAction().equals(ACTION_WIDGET_RECEIVER)) { if(wifiState != WifiManager.WIFI_STATE_ENABLING || wifiState != WifiManager.WIFI_STATE_DISABLING) { switchToggle(context); } } AppWidgetManager myAWM = AppWidgetManager.getInstance(context); ComponentName cn = new ComponentName(context, WifiWidgetLarge.class); onUpdate(context, myAWM, myAWM.getAppWidgetIds(cn)); } </code></pre> <p>This works fine on the smaller widget, which is just a toggle switch, but on the larger widget the exact same code doesn't produce the correct results. It shows the hourglass while disabling, but not while enabling. It seems that the intent is being received too late to display anything, as debug logs show that it is eventually being received. It's just not coming in with WIFI_STATE_ENABLING until immediately before the state changes to WIFI_STATE_ENABLED.</p> <p>Most baffling of all, the widget works fine on my tablet, and my roommate's phone, just not on my phone. However, I don't want to release it until I can be more sure of its performance. Any ideas?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload