Skip to content
This repository has been archived by the owner on Mar 11, 2019. It is now read-only.

Is it possible to support WifiManager.NETWORK_STATE_CHANGED_ACTION? #5

Closed
pserwylo opened this issue Aug 20, 2015 · 6 comments
Closed

Comments

@pserwylo
Copy link

This may be a long shot, and I am currently not able to think of a specific way to implement this, but can anybody think of a way to support broadcasting a WifiManager.NETWORK_STATE_CHANGED_ACTION intent when the WiFi AP gets enabled or disabled?

This is the way that the WifiManager currently notifies Android apps that they have gained or lost access to a wireless network. It would be extremely helpful to be able to be notified when a WiFi AP is connected to or disconnected from.

There may or may not be some underlying events/broadcasts that can be retrieved via, e.g. BroadcastReceivers or maybe some lower level thing which is only accessible via reflection that I'm unware of.

@mvdan
Copy link
Owner

mvdan commented Aug 24, 2015

You mean when someone connects or disconnects from our AP?

@pserwylo
Copy link
Author

Nah, this is for when the device with the AP running either enables or disables the AP. I misspoke in the original description by referring to it as "connects/disconnects". Sorry for the confusion.

@mvdan
Copy link
Owner

mvdan commented Aug 24, 2015

I am guessing you also want to be notified whenever the AP is enabled or disabled by the user, not only the library.

I can't find any callback system in Android to do such a thing. So we have two options:

  • Expect the app to call isEnabled() on an async thread repeatedly (e.g. every second)
  • We call isEnabled() on an async thread repeatedly (e.g. every second) and add a watcher/callback API to the library

I'm guessing the second is the best option. After all, this library is already hacky enough, with the reflection and all. Adding a callback system that internally polls should be fine, if we let the app define how often to poll (with a default to e.g. 1s) and as long as we don't do the polling work if no watchers are registered.

@luispereira
Copy link

Isn't this what you are looking for?

android.net.conn.TETHER_STATE_CHANGED

@mvdan
Copy link
Owner

mvdan commented Nov 28, 2016

@luispereira maybe - the docs say:

     * Broadcast Action: A tetherable connection has come or gone.
     * Uses {@code ConnectivityManager.EXTRA_AVAILABLE_TETHER},
     * {@code ConnectivityManager.EXTRA_ACTIVE_TETHER} and
     * {@code ConnectivityManager.EXTRA_ERRORED_TETHER} to indicate
     * the current state of tethering.  Each include a list of
     * interface names in that state (may be empty).

I don't have time to work on this at the moment, but will review a patch.

@mvdan
Copy link
Owner

mvdan commented Feb 27, 2018

Since there seems to be little interest to write this, I'm going to close this issue for now as I don't intend to work on it myself. Feel free to reopen or comment if you'd like to work on it.

@mvdan mvdan closed this as completed Feb 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants