I have an Android device that has a WIFI adapter but no screen and no input devices. I want to use it as a silent server in my local network that runs / offers some services and will eventually be configurable via the internet. The service app will be pre-installed and launch upon boot. The problem is the initial configuration (mainly join the local WIFI network).
My idea is: Develop a Java GUI app that is used for the initial setup via USB.
Let's assume I get the desktop app to find and communicate with the Android service via the ADK (I will be happy to share here once I succeed). That way I will be able to use my screen & keyboard to configure it. Now the problem is:
How can I (on the Android device) obtain a list of WIFI netorks that the Android device finds and how can I tell it to connect to a selected network (with a provided password)?
Is there maybe a better way to achieve what I am trying to?
The WifiManager
class should be helpful:
This class provides the primary API for managing all aspects of Wi-Fi connectivity. Get an instance of this class by calling Context.getSystemService(Context.WIFI_SERVICE). It deals with several categories of items:
- The list of configured networks. The list can be viewed and updated, and attributes of individual entries can be modified.
- The currently active Wi-Fi network, if any. Connectivity can be established or torn down, and dynamic information about the state of the network can be queried.
- Results of access point scans, containing enough information to make decisions about what access point to connect to.
- It defines the names of various Intent actions that are broadcast upon any sort of change in Wi-Fi state.
This is the API to use when performing Wi-Fi specific operations. To perform operations that pertain to network connectivity at an abstract level, use ConnectivityManager.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.