summaryrefslogtreecommitdiff
path: root/client/activity-demo/Piztor/src/com/example/piztor/GPSTracker.java
diff options
context:
space:
mode:
Diffstat (limited to 'client/activity-demo/Piztor/src/com/example/piztor/GPSTracker.java')
-rw-r--r--client/activity-demo/Piztor/src/com/example/piztor/GPSTracker.java107
1 files changed, 57 insertions, 50 deletions
diff --git a/client/activity-demo/Piztor/src/com/example/piztor/GPSTracker.java b/client/activity-demo/Piztor/src/com/example/piztor/GPSTracker.java
index e592ba3..13cb868 100644
--- a/client/activity-demo/Piztor/src/com/example/piztor/GPSTracker.java
+++ b/client/activity-demo/Piztor/src/com/example/piztor/GPSTracker.java
@@ -1,4 +1,5 @@
package com.example.piztor;
+
import android.app.AlertDialog;
import android.app.Service;
import android.content.Context;
@@ -33,7 +34,7 @@ public class GPSTracker extends Service implements LocationListener {
private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10; // 10 meters
// The minimum time between updates in milliseconds
- private static final long MIN_TIME_BW_UPDATES = 10 * 60 * 1; // 1 minute
+ private static final long MIN_TIME_BW_UPDATES = 1000 * 10; // 10 seconds
// Declaring a Location Manager
protected LocationManager locationManager;
@@ -56,7 +57,7 @@ public class GPSTracker extends Service implements LocationListener {
isNetworkEnabled = locationManager
.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
- if (!isGPSEnabled && !isNetworkEnabled) {
+ if (!isGPSEnabled) {
// no network provider is enabled
} else {
this.canGetLocation = true;
@@ -101,79 +102,84 @@ public class GPSTracker extends Service implements LocationListener {
return location;
}
-
+
/**
- * Stop using GPS listener
- * Calling this function will stop using GPS in your app
- */
- public void stopUsingGPS(){
- if(locationManager != null){
+ * Stop using GPS listener Calling this function will stop using GPS in your
+ * app
+ * */
+ public void stopUsingGPS() {
+ if (locationManager != null) {
locationManager.removeUpdates(GPSTracker.this);
- }
+ }
}
-
+
/**
* Function to get latitude
- */
- public double getLatitude(){
- if(location != null){
+ * */
+ public double getLatitude() {
+ if (location != null) {
latitude = location.getLatitude();
}
-
+
// return latitude
return latitude;
}
-
+
/**
* Function to get longitude
- */
- public double getLongitude(){
- if(location != null){
+ * */
+ public double getLongitude() {
+ if (location != null) {
longitude = location.getLongitude();
}
-
+
// return longitude
return longitude;
}
-
+
/**
* Function to check GPS/wifi enabled
+ *
* @return boolean
- */
+ * */
public boolean canGetLocation() {
return this.canGetLocation;
}
-
+
/**
- * Function to show settings alert dialog
- * On pressing Settings button will lauch Settings Options
- */
- public void showSettingsAlert(){
+ * Function to show settings alert dialog On pressing Settings button will
+ * lauch Settings Options
+ * */
+ public void showSettingsAlert() {
AlertDialog.Builder alertDialog = new AlertDialog.Builder(mContext);
-
- // Setting Dialog Title
- alertDialog.setTitle("GPS is settings");
-
- // Setting Dialog Message
- alertDialog.setMessage("GPS is not enabled. Do you want to go to settings menu?");
-
- // On pressing Settings button
- alertDialog.setPositiveButton("Settings", new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog,int which) {
- Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
- mContext.startActivity(intent);
- }
- });
-
- // on pressing cancel button
- alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- dialog.cancel();
- }
- });
-
- // Showing Alert Message
- alertDialog.show();
+
+ // Setting Dialog Title
+ alertDialog.setTitle("GPS is settings");
+
+ // Setting Dialog Message
+ alertDialog
+ .setMessage("GPS is not enabled. Do you want to go to settings menu?");
+
+ // On pressing Settings button
+ alertDialog.setPositiveButton("Settings",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ Intent intent = new Intent(
+ Settings.ACTION_LOCATION_SOURCE_SETTINGS);
+ mContext.startActivity(intent);
+ }
+ });
+
+ // on pressing cancel button
+ alertDialog.setNegativeButton("Cancel",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.cancel();
+ }
+ });
+
+ // Showing Alert Message
+ alertDialog.show();
}
@Override
@@ -196,4 +202,5 @@ public class GPSTracker extends Service implements LocationListener {
public IBinder onBind(Intent arg0) {
return null;
}
+
}