Click here to Skip to main content
15,881,967 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am working on a WiFi intensive mobile application, where the code scans APs to connect and investigate them...
I'm using Android Studio and the emulators with it... After a lot of reading I came to conclusion, that can not access those APs from within the emulator, but have to use a real phone...
I'm looking for clarification on this...

What I have tried:

Lot of reading and searching for samples and possible extensions/updates...
Posted
Updated 15-Jan-19 19:13pm
v2
Comments
David Crow 16-Jan-19 10:25am    
"After a lot of reading I came to conclusion, that can not access those APs from within the emulator, but have to use a real phone.."

Have you looked at the AP called AndroidWifi?
Kornfeld Eliyahu Peter 16-Jan-19 13:24pm    
That's an emulated AP (and only for very new API levels) - I try to look for real APs of real devices (I created)... On the real phone it works (with room for bugs), but on the emulator does not (even the host computer does see the APs)... I just wan't to be sure that I understood right that this is the case and didn't missed something small but valuable to me...
David Crow 16-Jan-19 15:28pm    
But it's an access point nonetheless. Your code to search for APs and connect to one would not change, whether it's an emulated one or a physical one right next to you.
Kornfeld Eliyahu Peter 16-Jan-19 15:34pm    
The code to search for APs is there and working, but without a true device that can access calls behind that AP it is not much use, so AndriodWiFi is no use for me in this case...
David Crow 18-Jan-19 23:21pm    
I put together this code to run on my emulator, once with Wi-Fi turned off, and again with it turned on. It printed the correct results each time.

ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
if (cm != null)
{
    NetworkInfo ni = cm.getNetworkInfo(ConnectivityManager.TYPE_ETHERNET);
    if (ni != null && ni.isAvailable())
    {
        Log.d("Test2", "ETHERNET is available");
        if (ni.isConnected())
            Log.d("Test2", "ETHERNET is connected");
        else
            Log.d("Test2", "ETHERNET is not connected");
    }
    else
        Log.d("Test2", "ETHERNET is not available");

    ni = cm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
    if (ni != null && ni.isAvailable())
    {
        Log.d("Test2", "MOBILE is available");
        if (ni.isConnected())
            Log.d("Test2", "MOBILE is connected");
        else
            Log.d("Test2", "MOBILE is not connected");
    }
    else
        Log.d("Test2", "MOBILE is not available");

    ni = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
    if (ni != null && ni.isAvailable())
    {
        Log.d("Test2", "WIFI is available");
        if (ni.isConnected())
            Log.d("Test2", "WIFI is connected");
        else
            Log.d("Test2", "WIFI is not connected");
    }
    else
        Log.d("Test2", "WIFI is not available");
}
Of course, I may just not be understanding your issue.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900