Good Day, I have an app with 2 activities: main and details page.
When there is internet connection user can navigate from main to details page. When no internet connection he can`t do that.
The problem is: When I`m in details page and switch off wifi I would like to finish this activity, how can I implement this functionality? I have check in main activity class something like that:
private boolean isNetworkAvailable() { ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); return activeNetworkInfo != null && activeNetworkInfo.isConnected(); }
It`s works fine when I start the app with internet or without that, but when I switch off the wifi at runtime it doesn`t works.
Anyway, thank you!