android GPRS detection network?

756 Views Asked by At

sorry for my question is perhpas stupid, but actually i'm newer to the world of android (work with xamarin android and android studio => a little).

I work on an APP who must to connect to network (mobile / wifi ).

I would like to understand the GPRS signal and for this i have some knowledge about it BUT NOT not sure about my experience ..

It's better to confirm with some stackOverFlow expert :)

1- for me , GPRS is the network mobile (2g, 3g, lte, ..) ? 2- the device detect AUTOMATICALLY this GPRS signal ? 3- For detecting this GPRS signal, we just need to add a SIM card into a device ? 4- a device CAN'T connect in several network (GPRS and wifi) ? 5- if some network(gprs and wifi) are available, the device will connect to the better network automatically ?

Thanks for your time and all your knowledge

1

There are 1 best solutions below

4
Luca Nicoletti On BEST ANSWER

Have a look here.

This is to determine if you have connection:

ConnectivityManager cm =
        (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);

NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
boolean isConnected = activeNetwork != null &&
                      activeNetwork.isConnectedOrConnecting();

and this is to verify if you're on WiFi:

boolean isWiFi = activeNetwork.getType() == ConnectivityManager.TYPE_WIFI;