Android Open Source - noxdroidandroidapp Connectivity Test






From Project

Back to project page noxdroidandroidapp.

License

The source code is released under:

MIT License

If you think the Android project noxdroidandroidapp listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package dk.itu.noxdroid.experiments;
//from   ww  w. ja  v a  2 s .  c  o  m
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.AsyncTask;
import android.os.Handler;
import android.util.Log;
import android.widget.ProgressBar;
import dk.itu.noxdroid.service.NoxDroidService;

public class ConnectivityTest extends AsyncTask<Object, Void, Boolean> {
  ProgressBar pb;
  NoxDroidService context;
  Handler messenger;
  private String TAG = "NoxDroid_ConnectivityTest"; 

  @Override
  protected void onPreExecute() {
    
  }

  @Override
  protected Boolean doInBackground(Object... params) {
    try {
      context = (NoxDroidService) params[0];
      
    } catch (Exception e) {
      Log.e(TAG, e.getMessage());
    }
    final ConnectivityManager connMan = (ConnectivityManager) context
        .getSystemService(Context.CONNECTIVITY_SERVICE);
    final NetworkInfo wifiInfo = connMan
        .getNetworkInfo(ConnectivityManager.TYPE_WIFI);
    final NetworkInfo mobileInfo = connMan
        .getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
    return wifiInfo.isAvailable() || mobileInfo.isAvailable();
  }

  @Override
  protected void onPostExecute(Boolean result) {
    Log.d(TAG, "PostExecute ConnTest");
    if (result) {
      
//      Message.obtain(messenger,
//          NoxDroidService.STATUS_CONNECTIVITY_SUCCESS).sendToTarget();
      context.notify(NoxDroidService.STATUS_CONNECTIVITY_OK);

    } else {
//      Message.obtain(messenger,
//          NoxDroidService.STATUS_CONNECTIVITY_FAILURE).sendToTarget();
      context.notify(NoxDroidService.ERROR_NO_CONNECTIVITY);
    }
  }
}




Java Source Code List

dk.itu.noxdroid.NoxDroidActivity.java
dk.itu.noxdroid.NoxDroidApp.java
dk.itu.noxdroid.NoxDroidMainActivity.java
dk.itu.noxdroid.cloudservice.NoxDroidAppEngineUtils.java
dk.itu.noxdroid.database.NoxDroidDbAdapter.java
dk.itu.noxdroid.experiments.ConnectivityTest.java
dk.itu.noxdroid.experiments.DbAdapter.java
dk.itu.noxdroid.experiments.IOIOActivity.java
dk.itu.noxdroid.experiments.IOIOSensorActivity.java
dk.itu.noxdroid.experiments.NoxDroidGPSActivity.java
dk.itu.noxdroid.geocommons.api.DataSet.java
dk.itu.noxdroid.ioio.IOIOConnectedTestThread.java
dk.itu.noxdroid.ioio.IOIOEventListener.java
dk.itu.noxdroid.ioio.NoxDroidIOIOThread.java
dk.itu.noxdroid.location.GPSLocationService.java
dk.itu.noxdroid.location.SkyHookLocationService.java
dk.itu.noxdroid.model.LocationSensor.java
dk.itu.noxdroid.model.Location.java
dk.itu.noxdroid.model.NoxDroid.java
dk.itu.noxdroid.model.NoxSensor.java
dk.itu.noxdroid.model.Nox.java
dk.itu.noxdroid.model.Sensor.java
dk.itu.noxdroid.model.Track.java
dk.itu.noxdroid.service.NoxDroidService.java
dk.itu.noxdroid.setup.PreferencesActivity.java
dk.itu.noxdroid.tracks.TracksListActivity.java
dk.itu.noxdroid.util.GPSUtil.java
dk.itu.noxdroid.util.Line.java
dk.itu.noxdroid.util.SensorDataUtil.java