Android Open Source - EnergyWastingApp G P S Coord Search






From Project

Back to project page EnergyWastingApp.

License

The source code is released under:

Copyright ? 2013-2014 Pekka Ekman <pekka.ekman@aalto.fi> 2013 Babujee Jerome Robin <robin.babujeejerome@aalto.fi> Permission is hereby granted, free of charge, to any person obtaining a ...

If you think the Android project EnergyWastingApp 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 fi.aalto.pekman.energywastingapp.components;
//  www  . j  a  v a 2s  . c o  m
import android.content.Context;
import android.content.Intent;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;



public class GPSCoordSearch extends Component implements LocationListener{


  private static LocationManager lm = null;
  private static boolean running = false;
  
  @Override
  public String getName() { return "GPSSearch"; }

  @Override
  public void start() {
    lm = (LocationManager)context.getSystemService(Context.LOCATION_SERVICE);
    if(lm.isProviderEnabled(LocationManager.GPS_PROVIDER)){
      markTurnedOn();
      running = true;
      lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
    } else {
      context.startActivityForResult(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS), 100);
      if(lm.isProviderEnabled(LocationManager.GPS_PROVIDER)){
        running = true;
        markTurnedOn();
        lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
      } else {
        running = false;
        Log.e("GPSCoordSearch", "GPS cannot be turned on!");
        markTurnedOff();
      }
    }
    
  }

  @Override
  public void stop() {
    if(null != lm && GPSCoordSearch.running){
      lm.removeUpdates(this);
      markTurnedOff();
    }
  }

  @Override
  public void onPause() {
    if(!GPSCoordSearch.running){
      markTurnedOff();
    }
  }

  @Override
  public void onLocationChanged(Location location) {
  }

  @Override
  public void onProviderDisabled(String provider) {
  }

  @Override
  public void onProviderEnabled(String provider) {
  }

  @Override
  public void onStatusChanged(String provider, int status, Bundle extras) {
  }
  
  
}




Java Source Code List

fi.aalto.pekman.energywastingapp.MainActivity.java
fi.aalto.pekman.energywastingapp.components.AbstractCamera.java
fi.aalto.pekman.energywastingapp.components.AbstractFileWriter.java
fi.aalto.pekman.energywastingapp.components.AppDirFileWriter.java
fi.aalto.pekman.energywastingapp.components.BlueToothBurn.java
fi.aalto.pekman.energywastingapp.components.CPUBurn.java
fi.aalto.pekman.energywastingapp.components.Component.java
fi.aalto.pekman.energywastingapp.components.Display.java
fi.aalto.pekman.energywastingapp.components.ExtStorageFileWriter.java
fi.aalto.pekman.energywastingapp.components.GPSCoordSearch.java
fi.aalto.pekman.energywastingapp.components.RecordAudio.java
fi.aalto.pekman.energywastingapp.components.StillCamera.java
fi.aalto.pekman.energywastingapp.components.TonePlay.java
fi.aalto.pekman.energywastingapp.components.Vibration.java
fi.aalto.pekman.energywastingapp.components.VideoCamera.java
fi.aalto.pekman.energywastingapp.components.WiFiDataTransfer.java