I have SplashActivity, Activity A and Activity B.
When the Internet is not available, Splash activity redirects to Activity A and when Internet is available and is connected SplashActivity redirects to Activity B.
I would like to immediately close the Activity A when user is connected itself and Open Activity B when user is still inside the app and he open his wifi or mobile Data.
Here is the code I'm using in SplahsActivity to redirect to Activity A and Activity B as per Network status
public static boolean isNetworkStatusAvialable(Context context) {
ConnectivityManager cm =
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
return activeNetwork != null &&
activeNetwork.isConnectedOrConnecting();
}
and I check with
if (isNetworkStatusAvialable(getApplicationContext())) {
// Load Activity B
} else {
Load Activity A and Toast Message, " No Internet"
}
Thanks in advance.