How to use for example this method public static boolean isConnectedWifi (Context context) in another class?

3

In a class I am validating the connection to the network in Android, and I would like to validate if the true value of that method in another class is executed by another method.

Class 1

public static boolean isConnectedWifi(Context context) {
    return true;
}

Class 2

public void saveLocation(Context ctx){
    //Codigo ejecución si hay conexión.
}
    
asked by Julian 22.06.2016 в 22:49
source

1 answer

0

This is an example, where you use the context to call the isConnectedWifi() method which returns a boolean value, with this you can determine whether or not to execute your other method:

public void saveLocation(Context ctx){
   if(isConnectedWifi(ctx)){ 
    //Conectado ejecuta el método.
    }else{
    //NO Conectado.
   }    
}
    
answered by 22.06.2016 / 23:06
source