diff --git a/phoneClients/android/.idea/misc.xml b/phoneClients/android/.idea/misc.xml
index 2c4e995..b153e48 100644
--- a/phoneClients/android/.idea/misc.xml
+++ b/phoneClients/android/.idea/misc.xml
@@ -6,22 +6,5 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- false
-
diff --git a/phoneClients/android/.idea/vcs.xml b/phoneClients/android/.idea/vcs.xml
index def6a6a..a5dd086 100644
--- a/phoneClients/android/.idea/vcs.xml
+++ b/phoneClients/android/.idea/vcs.xml
@@ -2,6 +2,7 @@
+
diff --git a/phoneClients/android/.idea/workspace.xml b/phoneClients/android/.idea/workspace.xml
index 8c1cfb4..7e0b166 100644
--- a/phoneClients/android/.idea/workspace.xml
+++ b/phoneClients/android/.idea/workspace.xml
@@ -19,7 +19,13 @@
-
+
+
+
+
+
+
+
@@ -82,28 +88,21 @@
-
+
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
-
+
@@ -111,14 +110,14 @@
-
-
-
-
-
+
+
+
+
+
@@ -128,6 +127,14 @@
+
+
+
+
+
+
+
-
+
-
-
-
-
+
+
+
+
-
+
@@ -521,7 +533,6 @@
-
@@ -540,9 +551,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -552,7 +578,7 @@
-
+
@@ -590,6 +616,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -617,19 +656,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -714,6 +740,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ false
+
@@ -723,8 +766,8 @@
-
-
+
+
@@ -737,19 +780,19 @@
-
+
-
-
+
+
-
+
@@ -782,19 +825,21 @@
+
+
+
-
-
-
-
+
+
+
@@ -813,14 +858,14 @@
+
+
+
-
-
-
@@ -837,56 +882,58 @@
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
-
+
+
+
+
-
+
-
+
+
+
+
+
+
+
+
+
+
diff --git a/phoneClients/android/GpsTracker/src/main/AndroidManifest.xml b/phoneClients/android/GpsTracker/src/main/AndroidManifest.xml
index 3f8e6a0..d1da699 100644
--- a/phoneClients/android/GpsTracker/src/main/AndroidManifest.xml
+++ b/phoneClients/android/GpsTracker/src/main/AndroidManifest.xml
@@ -21,7 +21,8 @@
+ android:label="@string/app_name"
+ android:screenOrientation="portrait" >
diff --git a/phoneClients/android/GpsTracker/src/main/java/com/websmithing/gpstracker/GpsTrackerActivity.java b/phoneClients/android/GpsTracker/src/main/java/com/websmithing/gpstracker/GpsTrackerActivity.java
index 3b235a9..1beea45 100644
--- a/phoneClients/android/GpsTracker/src/main/java/com/websmithing/gpstracker/GpsTrackerActivity.java
+++ b/phoneClients/android/GpsTracker/src/main/java/com/websmithing/gpstracker/GpsTrackerActivity.java
@@ -20,19 +20,26 @@
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationRequest;
+import java.text.SimpleDateFormat;
+import java.util.TimeZone;
+import java.util.Date;
+import java.text.DateFormat;
+
+
public class GpsTrackerActivity extends ActionBarActivity implements LocationListener, GooglePlayServicesClient.ConnectionCallbacks,
GooglePlayServicesClient.OnConnectionFailedListener {
- private LocationRequest locationRequest;
- private LocationClient locationClient;
-
+ private static String TAG = "GpsTrackerActivity";
private static TextView longitudeTextView;
private static TextView latitudeTextView;
private static TextView accuracyTextView;
private static TextView providerTextView;
private static TextView timeStampTextView;
+ private LocationRequest locationRequest;
+ private LocationClient locationClient;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -44,48 +51,67 @@
.commit();
}
-/*
- // create a new global location parameters object
- locationRequest = LocationRequest.create();
- locationRequest.setInterval(5 * 1000);
- locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
- locationRequest.setFastestInterval(60 * 1000); // interval ceiling
-*/
int response = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
if(response == ConnectionResult.SUCCESS){
locationClient = new LocationClient(this,this,this);
locationClient.connect();
}
else{
- Log.e("GpsTrackerActivity", "google play service error: " + response);
+ Log.e(TAG, "google play service error: " + response);
}
}
// called when startTrackingButton is tapped
public void startTracking(View v) {
- Log.e("GpsTrackerActivity", "startTracking");
((Button) v).setText("stop tracking");
+ locationRequest = LocationRequest.create();
+ locationRequest.setInterval(60 * 1000);
+ locationRequest.setFastestInterval(60 * 1000); // the fastest rate in milliseconds at which your app can handle location updates
+ locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
+ locationClient.requestLocationUpdates(locationRequest, this);
+
+ //oneTimeLocationUpdate();
+ }
+
+ protected void oneTimeLocationUpdate() {
+ Log.e(TAG, "oneTimeLocationUpdate");
+
if (locationClient != null && locationClient.isConnected()) {
Location location = locationClient.getLastLocation();
- longitudeTextView.setText("longitude: " + location.getLongitude());
- latitudeTextView.setText("latitude: " + location.getLatitude());
-
- accuracyTextView.setText("accuracy: " + location.getAccuracy());
- providerTextView.setText("provider: " + location.getProvider());
- timeStampTextView.setText("timeStamp: " + location.getTime());
+ displayLocationData(location);
}
}
- // called when startTrackingButton is tapped
- public void stopTracking(View v) {
- Log.e("GpsTrackerActivity", "stopTracking");
- ((Button) v).setText("start tracking");
+ @Override
+ public void onLocationChanged(Location location) {
+ Log.e(TAG, "onLocationChanged");
+ if (location != null) {
+ displayLocationData(location);
+ }
+ }
+
+ protected void displayLocationData(Location location) {
+ DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ dateFormat.setTimeZone(TimeZone.getDefault());
+ Date date = new Date(location.getTime());
+
+ longitudeTextView.setText("longitude: " + location.getLongitude());
+ latitudeTextView.setText("latitude: " + location.getLatitude());
+ accuracyTextView.setText("accuracy: " + location.getAccuracy());
+ providerTextView.setText("provider: " + location.getProvider());
+ timeStampTextView.setText("timeStamp: " + dateFormat.format(date));
+ }
+
+ public void stopTracking(View v) {
+ Log.e(TAG, "stopTracking");
+ ((Button) v).setText("start tracking");
}
@Override
protected void onStart() {
+ Log.e(TAG, "onStart");
super.onStart();
// Connect the client.
//mLocationClient.connect();
@@ -93,17 +119,16 @@
@Override
protected void onStop() {
- // Disconnecting the client invalidates it.
- //mLocationClient.disconnect();
+ Log.e(TAG, "onStop");
+
+ if (locationClient != null && locationClient.isConnected()) {
+ locationClient.removeLocationUpdates(this);
+ locationClient.disconnect();
+ }
+
super.onStop();
}
- @Override
- public void onLocationChanged(Location location) {
-
- // LocationUtils.getLatLng(this, location);
- }
-
/**
* Called by Location Services when the request to connect the
* client finishes successfully. At this point, you can
@@ -111,6 +136,7 @@
*/
@Override
public void onConnected(Bundle bundle) {
+ Log.e(TAG, "onConnected");
}
@@ -120,18 +146,18 @@
*/
@Override
public void onDisconnected() {
+ Log.e(TAG, "onDisconnected");
}
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
+ Log.e(TAG, "onConnectionFailed");
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
-
- // Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.gps_tracker, menu);
return true;
}
@@ -148,9 +174,6 @@
return super.onOptionsItemSelected(item);
}
- /**
- * A placeholder fragment containing a simple view.
- */
public static class PlaceholderFragment extends Fragment {
public PlaceholderFragment() {
@@ -160,13 +183,11 @@
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_gpstracker, container, false);
-
longitudeTextView = (TextView)rootView.findViewById(R.id.longitudeTextView);
latitudeTextView = (TextView)rootView.findViewById(R.id.latitudeTextView);
accuracyTextView = (TextView)rootView.findViewById(R.id.accuracyTextView);
providerTextView = (TextView)rootView.findViewById(R.id.providerTextView);
timeStampTextView = (TextView)rootView.findViewById(R.id.timeStampTextView);
-
return rootView;
}
}