0
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 unique class for this and call in Activity I need to control this.
I don’t have much experience in this and I even found some models but I didn’t understand very well.
You want to create a model that when instantiated check that connection?
– Costamilam
That’s right, so you don’t have to insert a repeat code snippet each time. @Guilhermecostamilam
– TiagoIB