is Connected by Context.CONNECTIVITY_SERVICE : Service « Network « Android

Home
Android
1.2D Graphics
2.Animation
3.Core Class
4.Database
5.Date Type
6.Development
7.File
8.Game
9.Hardware
10.Media
11.Network
12.Security
13.UI
14.User Event
Android » Network » Service 
is Connected by Context.CONNECTIVITY_SERVICE
  


//package test.easytask.util;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

class NetworkUtil {
  public static boolean isConnected(Context context) {
    ConnectivityManager cm = (ConnectivityManagercontext.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo ni = cm.getActiveNetworkInfo();
    if (ni != null) {
      return cm.getActiveNetworkInfo().isConnected();
    }
    return false;
  }
}

   
    
  
Related examples in the same category
1.Map Service
2.Widget Service
3.Restful web service task
4.Search with Restful service
5.Post Restful service
6.Tracker Service
7.Weather web service
8.Access a Web service using GET
9.Alarm service
10.Get Running Services Info
11.Local service demo
12.extends Service
13.Service structure
14.Clock Back Service
15.Voice Recognition Service
16.BeatService extends Service and Thread
17.TimeoutService (beta). Here you can register a timeout.
18.Timeout Service
19.Screenshot Service
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.