jueves, 30 de enero de 2014

Get connectivity in android

Common solution:
ConnectivityManager cm =
        (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
 
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
boolean isConnected = activeNetwork != null &&
                      activeNetwork.isConnectedOrConnecting();

Using a broadcast receiver when the network state change:

   
      
   


No hay comentarios:

Publicar un comentario