Changing WiFi network on Android

Hi! I need to change my WiFi network in my app, but I don’t know how. Can you tell me how? If I haven’t searched enough, it’s okay if you let me know. Thanks!

@KTibow ====

though i think i have already answered to that here
that is easy: you use the WifiManager API
create an instance of it
list all wifiSpots
put them in a list
disconnect from all
connect to what you want
(of course you need the wep code)

Can you give me an example?

I’m pinging you, @akenaton. Can you give me an example?

@KTibow ===
example here for scanning:
https://developer.android.com/guide/topics/connectivity/wifi-scan
dont forget permissions (3)

Thanks! Do you know what libraries to import, @akenaton?

@KTibow ===

import java.util.List;/// FOR LISTING
import android.content.Context;// for creating the WIFIM instance
import android.content.BroadcastReceiver;////for creating the receiver
import android.content.Intent;///for adding an intent to it
import android.content.IntentFilter;///// for filtering the receipts
import android.net.wifi.ScanResult;/// for scanning
import android.net.wifi.WifiManager;///FIRSTLY
import android.app.Activity;/// FRAGMENT
import android.net.wifi.WifiConfiguration.KeyMgmt;/// For the key WEP
import android.net.wifi.WifiConfiguration;///for creating a new wifi config
1 Like