diff --git a/pandora_agents/android/ChangeLog b/pandora_agents/android/ChangeLog index 5554e67279..7d5df567ef 100644 --- a/pandora_agents/android/ChangeLog +++ b/pandora_agents/android/ChangeLog @@ -1,3 +1,11 @@ +2013-05-01 Mark Holland + + * src/pandroid/agent/PandroidAgentListener.java: Changed gps module + to update coordinates after a time of "interval" AND "15 metres" if + no change then uses lastKnownLocation. + + * Pandroid Agent v3.0_iso-8859-1.apk: Updated to latest version. + 2013-04-28 Mark Holland * layout/spinner.xml: Changed spinnner text color to green. diff --git a/pandora_agents/android/Pandroid Agent v3.0_iso-8859-1.apk b/pandora_agents/android/Pandroid Agent v3.0_iso-8859-1.apk index 14ce60823d..c85815df0f 100644 Binary files a/pandora_agents/android/Pandroid Agent v3.0_iso-8859-1.apk and b/pandora_agents/android/Pandroid Agent v3.0_iso-8859-1.apk differ diff --git a/pandora_agents/android/Pandroid Agent v3.0_writeUTF.apk b/pandora_agents/android/Pandroid Agent v3.0_writeUTF.apk deleted file mode 100644 index 8fc67da12d..0000000000 Binary files a/pandora_agents/android/Pandroid Agent v3.0_writeUTF.apk and /dev/null differ diff --git a/pandora_agents/android/src/pandroid/agent/PandroidAgentListener.java b/pandora_agents/android/src/pandroid/agent/PandroidAgentListener.java index e70b092f29..99d9e4d02a 100644 --- a/pandora_agents/android/src/pandroid/agent/PandroidAgentListener.java +++ b/pandora_agents/android/src/pandroid/agent/PandroidAgentListener.java @@ -560,101 +560,73 @@ public class PandroidAgentListener extends Service { return module_xml; } - private void gpsLocation(){ - - - //Start a location listener - LocationListener onLocationChange=new LocationListener() { - public void onLocationChanged(Location loc) { - Log.d("latitude",""+loc.getLatitude()); - Log.d("Longitude",""+loc.getLongitude()); - - } - - public void onProviderDisabled(String provider) { - // required for interface, not used - } - - public void onProviderEnabled(String provider) { - // required for interface, not used - } - - public void onStatusChanged(String provider, int status, - Bundle extras) { - // required for interface, not used - } - }; - - locmgr.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,10000.0f,onLocationChange); - - } -// private void gpsLocation() { -// // Starts with GPS, if no GPS then gets network location + + private void gpsLocation() { + // Starts with GPS, if no GPS then gets network location // -// LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); -// List providers = lm.getProviders(true); -// Log.d("PANDROID providers count", "" + providers.size()); -// -//// /* Loop over the array backwards, and if you get an accurate location, then break out the loop*/ -//// Location loc = null; -//// -//// for (int i=providers.size()-1; i>=0; i--) { -//// Log.d("PANDROID providers", providers.get(i)); -//// loc = lm.getLastKnownLocation(providers.get(i)); -//// if (loc != null) break; -//// } -//// -//// if (loc != null) { -//// Log.d("PANDROID", "loc != null"); -//// //if(latitude != loc.getLatitude() || longitude != loc.getLongitude()) { -//// lastGpsContactDateTime = getHumanDateTime(-1); -//// //`} -//// Log.d("LATITUDE",Double.valueOf(loc.getLatitude()).toString()); -//// Log.d("LONGITUDE",Double.valueOf(loc.getLongitude()).toString()); -//// putSharedData("PANDROID_DATA", "latitude", Double.valueOf(loc.getLatitude()).toString(), "float"); -//// putSharedData("PANDROID_DATA", "longitude", Double.valueOf(loc.getLongitude()).toString(), "float"); -//// } -//// else { -// Criteria criteria = new Criteria(); -// criteria.setAccuracy(Criteria.ACCURACY_COARSE); -// criteria.setPowerRequirement(Criteria.POWER_LOW); -// criteria.setAltitudeRequired(false); -// criteria.setBearingRequired(false); -// criteria.setCostAllowed(true); -// String bestProvider = lm.getBestProvider(criteria, true); -// -// // If not provider found, abort GPS retrieving -// if (bestProvider == null) { -// Log.e("LOCATION", "No location provider found!"); -// return; -// } -// -// lm.requestLocationUpdates(bestProvider, Core.defaultInterval, 1000, -// new LocationListener() { -// public void onLocationChanged(Location location) { -// Log.d("Best latitude", Double.valueOf(location.getLatitude()).toString()); -// putSharedData("PANDROID_DATA", "latitude", -// Double.valueOf(location.getLatitude()).toString(), "float"); -// Log.d("Best longitude", Double.valueOf(location.getLongitude()).toString()); -// putSharedData("PANDROID_DATA", "longitude", -// Double.valueOf(location.getLongitude()).toString(), "float"); -// } -// public void onStatusChanged(String s, int i, Bundle bundle) { -// -// } -// public void onProviderEnabled(String s) { -// // try switching to a different provider -// } -// public void onProviderDisabled(String s) { -// putSharedData("PANDROID_DATA", "enabled_location_provider", -// "disabled", "string"); -// } -// }); -// //} -// -// } + LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); + List providers = lm.getProviders(true); + Log.d("PANDROID providers count", "" + providers.size()); + + /* Loop over the array backwards, and if you get an accurate location, then break out the loop*/ + Location loc = null; + + for (int i=providers.size()-1; i>=0; i--) { + Log.d("PANDROID providers", providers.get(i)); + loc = lm.getLastKnownLocation(providers.get(i)); + if (loc != null) break; + } + + if (loc != null) { + Log.d("PANDROID", "loc != null"); + //if(latitude != loc.getLatitude() || longitude != loc.getLongitude()) { + lastGpsContactDateTime = getHumanDateTime(-1); + //`} + Log.d("LATITUDE",Double.valueOf(loc.getLatitude()).toString()); + Log.d("LONGITUDE",Double.valueOf(loc.getLongitude()).toString()); + putSharedData("PANDROID_DATA", "latitude", Double.valueOf(loc.getLatitude()).toString(), "float"); + putSharedData("PANDROID_DATA", "longitude", Double.valueOf(loc.getLongitude()).toString(), "float"); + } + Criteria criteria = new Criteria(); + criteria.setAccuracy(Criteria.ACCURACY_COARSE); + criteria.setPowerRequirement(Criteria.POWER_LOW); + criteria.setAltitudeRequired(false); + criteria.setBearingRequired(false); + criteria.setCostAllowed(true); + String bestProvider = lm.getBestProvider(criteria, true); + + // If not provider found, abort GPS retrieving + if (bestProvider == null) { + Log.e("LOCATION", "No location provider found!"); + return; + } + + lm.requestLocationUpdates(bestProvider, Core.interval, 15, + new LocationListener() { + public void onLocationChanged(Location location) { + Log.d("Best latitude", Double.valueOf(location.getLatitude()).toString()); + putSharedData("PANDROID_DATA", "latitude", + Double.valueOf(location.getLatitude()).toString(), "float"); + Log.d("Best longitude", Double.valueOf(location.getLongitude()).toString()); + putSharedData("PANDROID_DATA", "longitude", + Double.valueOf(location.getLongitude()).toString(), "float"); + } + public void onStatusChanged(String s, int i, Bundle bundle) { + + } + public void onProviderEnabled(String s) { + // try switching to a different provider + } + public void onProviderDisabled(String s) { + putSharedData("PANDROID_DATA", "enabled_location_provider", + "disabled", "string"); + } + }); + //} + + } private void batteryLevel() {