Hello.
Currently I control screen by screen the type of internet connection to which the user is connected or not.
I use a method similar to this:
/*Check conection*/
ConnectivityManager manager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
//For 3G check
final boolean is3g = manager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE)
.isConnectedOrConnecting();
//For WiFi Check
boolean isWifi = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI)
.isConnectedOrConnecting();
if (!is3g && !isWifi){
Toast.makeText(AgendamentoActivity.this, "Sem conexão!! Verifique...", Toast.LENGTH_LONG).show();
finish();
}
I would like to know how I could create a single class for this and call it in Activity that I need to control it.
I do not have much experience in this and even found some models but I did not quite understand.