I'm trying to get the available Wifi list.
I have a separate class that holds the receiver.
public BroadcastReceiver WifiScanBroadcast = new BroadcastReceiver(){
public void onReceive(Context context, android.content.Intent intent)
{
results = wifiManager.getScanResults();
size = results.size();
};
I have instantiated the class with the variable wifiManager. Thats the onCreate function of my Activity:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_wifi_list);
wifiManager = new WifiApManager(this);
Intent i = registerReceiver(wifiManager.WifiScanBroadcast, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
}
This is what i use in the manifest:
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
When I'm getting to the registerReceiver, it returns Null. What is wrong?
I didn't really get what was wrong with my code, but moving to receiver to the activity(in the past the receiver was declared in another class) solved the problem. Now it works