When connect wifi, addNetwork method always returns -1. Solved : WiFi config - SSID = "\"" + SSID + "\""; Try this. in my case, work.