I have a main activity where I see that if I do not have internet in the onCreate
, the Firebase
( which has its own AsyncTask
) does not do its work, then the problem is that if I do not obtain information of the Firebase
, I can not do the setter of the adapter with the information and the activity would be empty. My question is, how to carry out the task of obtaining continuous Firebase
if I do not have internet? How can I get the FB
database once connected to the internet?
I have tried the following methods to do a boolean if I am connected or not and they do not help me at all ... even if I had the Wi-Fi, my warning that I was not connected ...
public boolean isOnline()
{
ConnectivityManager connMgr = (ConnectivityManager)
getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
return (networkInfo != null && networkInfo.isConnected());
}
and
public boolean isNetworkAvailable(Context context) {
ConnectivityManager connectivity =(ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivity == null) {
return false;
} else {
NetworkInfo[] info = connectivity.getAllNetworkInfo();
if (info != null) {
for (int i = 0; i < info.length; i++) {
if (info[i].getState() == NetworkInfo.State.CONNECTED) {
return true;
}
}
}
}
return false;
}
If the Firebase has its own "doInBackground" due to its Asynctask
, because when connecting to the internet (wifi or 3g) it does not give me the information to adapt it?
Thank you very much