Autoconnect
The host application can enable and disable Autoconnect using the setAutoconnectEnable method.
Please note:
Autoconnect is enabled by default.
If the Autoconnect is disabled, the SDK does not connect the device to the supported networks.
If the application disables the Autoconnect, only the application can re-enable the Autoconnect.
If the application disables the Autoconnect during a connection managed by SDK, the SDK stops immediately the connection.
Enable Autoconnect:
WimanSDK.setAutoconnectEnable(this, true);
Disable Autoconnect:
WimanSDK.setAutoconnectEnable(this, false);
Check if Autoconnect is working correctly:
Please note
Wiman Autoconnect could not work if:
Autoconnect is disabled
Device location is not enabled
User has not given permission to access device location
SDK has not been initialized yet
WimanSDK.isAutoconnectEnable(Context);
Preferences
Get the Autoconnect status (boolean)
WimanSDK.getPrefs(Context).autoConnectEnable
Check if Autoconnect is initialized (boolean)
WimanSDK.getPrefs(Context).initialized
Initialize
SDK Initialization
WimanSDK.initialize(Context, SDKkey);
SDK Initialization with Autoconnect start value (boolean)
WimanSDK.initialize(Context, SDKkey, defaultStart);
Opt-in Dialog
Please note: For more information about this dialog please see the FAQ.
Shows Dialog:
WimanSDK.showOptin(activity);
Shows Dialog with start value (boolean):
WimanSDK.showOptin(activity, defaultStart);
Shows Dialog with a specific theme (ThemeStyle.LIGHT / ThemeStyle.DARK):
WimanSDK.showOptin(activity, themeStyle);
Shows Dialog with start value (boolean) and a specific theme:
WimanSDK.showOptin(activity, defaultStart, themeStyle);
Password protected Wi-Fi autoconnect
Please note: Starting from SDK version 1.1.8, users are able to get automatically connected even to password protected Wiman community Wi-Fi. In order to do that the SDK needs to save on the user device information about Wi-Fi networks. Before start using the SDK, we suggest to cache at least the country where the user is in. If no countries have been downloaded, users are able to get connected only to open Wi-Fi.
Download a country:
WimanSDK.downloadNetwork(Context,ISO CODE,WimanSdkNetworksListener);
ISO CODE
country ISO 3166-1 alpha-2. Find out more hereWimanSdkNetworksListener
It receives two different callbacks: "onSuccess" or "onError"
Wi-Fi networks nearby
Please note: Starting from SDK version 1.1.8, the host app can browse Wi-Fi nearby cached information except the Wi-Fi passwords. It's very useful when the users are offline and developer wants to provide them with a list of available Wi-Fi nearby they can get connected to.
Get Wi-Fi nearby (method #1):
WimanSDK.searchNetwork(Context,lat,lng,radius,WimanSdkNetwoksSearchListener)
lat
latitudelng
longituderadius
in meterWimanSdkNetworksListener
It receives a list of Wiman networks
Get Wi-Fi nearby (method #2):
WimanSDK.searchNetwork(Context,bounds,WimanSdkNetwoksSearchListener)
bounds
Google maps boundsWimanSdkNetworksListener
It receives a list of Wiman networks
Networks
Returns a list of all connected networks:
WimanSDK.getConnected(Context);
Events
The host application can receive Wiman SDK events.
In order to receive the events, the host application must use a listener with addEventsListener method.
Available events are the following:
onConnect
to notify that the device has been connected to a WiFi network.onError
to notify that something went wrongonDisconnect
to notify that the device has been disconnected from the WiFi network previously connected thanks to Wiman SDK
WimanSDK.addEventsListener(new EventsListener() {
@Override
public void onConnect(String ssid, String bssid, int rssid, Location location) {
...
}
@Override
public void onError(String ssid, String bssid, Availability codeError) {
...
}
@Override
public void onDisconnect(long byteTot, long duration, String bssid) {
...
}
});