A
A
Anton Piskunov2014-09-03 16:17:49
Mobile development
Anton Piskunov, 2014-09-03 16:17:49

How to show splash-screen if there is no internet on iOS, Android, WP?

Hello,
there are three applications that crash if there is no internet. How can I handle the lack of Internet with a splash screen for three platforms?
Maybe there is some kind of dock, guide, documentation about it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
FanKiLL, 2014-09-04
@FanKiLL

public class NetworkManager {

    public static boolean isNetworkAvailable(Context context) {
        ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo networkInfo = cm.getActiveNetworkInfo();
        if (networkInfo != null && networkInfo.isConnected()) {
            return true;
        } else {
            return false;
        }
    }
}

and before each action where the network is needed, do this
if (NetworkManager.isNetworkAvailable(context)) {
    // делаем спокойно запрос например
} else {
    // если сети нет показываем Тост или 
    // кидаем на активити с красивым дизайном где просим сделать реконнект
}

Requires a permishin, add a permishin to the manifest
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

C
Copperfield, 2014-09-03
@Copperfield

Do you need documentation for checking your internet connection?
Each platform has its own way.
Write to Google how to check internet access android / ios / wp and get the solution with the first link.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question