// Path: at.attentec.com/android/at.attentec.client/src/com/attentec/LocationHelper.java
// public abstract static class LocationResult {
// 	/**
// 	 * Call back with the found location.
// 	 * @param location	found location
// 	 */
// 	public abstract void gotLocation(Location location);
// }
// 
// Path: at.attentec.com/android/at.attentec.client/src/com/attentec/Login.java
// public static class LoginException extends Exception {
// 	/**
// 	 *
// 	 */
// 	private static final long serialVersionUID = 1L;
// 
// 	/**
// 	 * No message constructor.
// 	 */
// 	public LoginException() {
// 
// 	}
// 
// 	/**
// 	 * Message constructor.
// 	 * @param description	description of exception
// 	 */
// 	public LoginException(final String description) {
// 		super(description);
// 	}
// }


import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.ByteArrayBuffer;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.location.Location;
import android.os.IBinder;
import android.preference.PreferenceManager;
import android.util.Log;
import com.attentec.LocationHelper.LocationResult;
import com.attentec.Login.LoginException;


			Date d = new Date();

			SharedPreferences.Editor editor = sp.edit();
			editor.putFloat("latitude", lat.floatValue());
			editor.putFloat("longitude", lng.floatValue());
			editor.putLong("location_updated_at", d.getTime() / DevelopmentSettings.MILLISECONDS_IN_SECOND);
			editor.commit();

			//check if we need to update the server
			if (d.getTime() - lastUpdatedToServer < PreferencesHelper.getLocationsUpdateInterval(ctx) / 2) {
				Log.d(TAG, "Not updating location to server, to soon since last time: " + (d.getTime() - lastUpdatedToServer));
				return;
			}

			Log.d(TAG, "Updating location to server");
			//get logindata for server contact
			Hashtable<String, List<NameValuePair>> postdata = ServerContact.getLogin(username, phoneKey);

			//add location to POST data
			List<NameValuePair> locationdata = new ArrayList<NameValuePair>();
			locationdata.add(new BasicNameValuePair("latitude", lat.toString()));
			locationdata.add(new BasicNameValuePair("longitude", lng.toString()));
			postdata.put("location", locationdata);

			//send location to server
			String url = "/app/app_update_user_info.json";

			try {
				ServerContact.postJSON(postdata, url, ctx);

// Path: at.attentec.com/android/at.attentec.client/src/com/attentec/LocationHelper.java
// public abstract static class LocationResult {
// 	/**
// 	 * Call back with the found location.
// 	 * @param location	found location
// 	 */
// 	public abstract void gotLocation(Location location);
// }
// 
// Path: at.attentec.com/android/at.attentec.client/src/com/attentec/Login.java
// public static class LoginException extends Exception {
// 	/**
// 	 *
// 	 */
// 	private static final long serialVersionUID = 1L;
// 
// 	/**
// 	 * No message constructor.
// 	 */
// 	public LoginException() {
// 
// 	}
// 
// 	/**
// 	 * Message constructor.
// 	 * @param description	description of exception
// 	 */
// 	public LoginException(final String description) {
// 		super(description);
// 	}
// }


// Path: at.attentec.com/android/at.attentec.client/src/com/attentec/AttentecService.java
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.ByteArrayBuffer;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.location.Location;
import android.os.IBinder;
import android.preference.PreferenceManager;
import android.util.Log;
import com.attentec.LocationHelper.LocationResult;
import com.attentec.Login.LoginException;


			Date d = new Date();

			SharedPreferences.Editor editor = sp.edit();
			editor.putFloat("latitude", lat.floatValue());
			editor.putFloat("longitude", lng.floatValue());
			editor.putLong("location_updated_at", d.getTime() / DevelopmentSettings.MILLISECONDS_IN_SECOND);
			editor.commit();

			//check if we need to update the server
			if (d.getTime() - lastUpdatedToServer < PreferencesHelper.getLocationsUpdateInterval(ctx) / 2) {
				Log.d(TAG, "Not updating location to server, to soon since last time: " + (d.getTime() - lastUpdatedToServer));
				return;
			}

			Log.d(TAG, "Updating location to server");
			//get logindata for server contact
			Hashtable<String, List<NameValuePair>> postdata = ServerContact.getLogin(username, phoneKey);

			//add location to POST data
			List<NameValuePair> locationdata = new ArrayList<NameValuePair>();
			locationdata.add(new BasicNameValuePair("latitude", lat.toString()));
			locationdata.add(new BasicNameValuePair("longitude", lng.toString()));
			postdata.put("location", locationdata);

			//send location to server
			String url = "/app/app_update_user_info.json";

			try {
				ServerContact.postJSON(postdata, url, ctx);

			} catch (LoginException e) {
