Would this be correct code for Android:
calling init from MyApplication.onCreate()
public class Connectivity {
static ConnectivityManager cm;
public static void init(Context context){
cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
}
public static boolean isConnected(){
activeNetwork = cm.getActiveNetworkInfo();
boolean isConnected = activeNetwork != null &&
activeNetwork.isConnected();
return isConnected;
}
Is using static
way to go for Android?
Will those static values stay longer than any activity or launched service (that will finish in an hour)?
There was related question Android Application Class Lifecycle but discussion went to Activities lifecycle.