protected void activateDataExchange() {
   IExchangeHandler[] vals = null;
   synchronized (handlers) {
     if (handlers.size() > 0) {
       vals = handlers.toArray(new IExchangeHandler[handlers.size()]);
     }
   }
   if (vals != null) {
     for (IExchangeHandler h : vals) {
       try {
         h.startExchange();
       } catch (Throwable t) {
         log.warn("Caught exception when invoke exchange handler :" + h, t);
       }
     }
   }
   lastActiveTime = System.currentTimeMillis();
 }
  protected int checkAvailableConnection() {
    try {
      ConnectivityManager connMgr =
          (ConnectivityManager)
              context
                  .getApplication()
                  .getAndroidApplication()
                  .getSystemService(Context.CONNECTIVITY_SERVICE);

      final android.net.NetworkInfo wifi = connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI);

      final android.net.NetworkInfo mobile =
          connMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);

      if (wifi.isConnected()) {
        return ConnectivityManager.TYPE_WIFI;
      } else if (mobile.isConnected() && (!mobile.isRoaming())) {
        return ConnectivityManager.TYPE_MOBILE;
      }
    } catch (Throwable t) {
      log.warn("Caught exception when checking network status", t);
    }
    return -1;
  }