diff --git a/SampleEasyLocator/app/build.gradle b/SampleEasyLocator/app/build.gradle
index 202d646..7d3ede9 100644
--- a/SampleEasyLocator/app/build.gradle
+++ b/SampleEasyLocator/app/build.gradle
@@ -10,6 +10,13 @@ android {
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+
+ // Enabling multi-dex support.
+ multiDexEnabled true
+ }
+ dexOptions {
+ incremental true
+ javaMaxHeapSize "4g"
}
buildTypes {
release {
diff --git a/SampleEasyLocator/app/src/main/java/com/pureix/sampleeasylocator/MainActivity.java b/SampleEasyLocator/app/src/main/java/com/pureix/sampleeasylocator/MainActivity.java
index 55d633a..381119f 100644
--- a/SampleEasyLocator/app/src/main/java/com/pureix/sampleeasylocator/MainActivity.java
+++ b/SampleEasyLocator/app/src/main/java/com/pureix/sampleeasylocator/MainActivity.java
@@ -17,6 +17,7 @@ import com.pureix.easylocator.controller.service.BatteryAPI;
import com.pureix.easylocator.controller.service.InternetAPI;
import com.pureix.easylocator.controller.service.LocationAPI;
import com.pureix.easylocator.controller.service.SmartLocationAPI;
+import com.pureix.easylocator.service.batteryService.bean.BatteryInformation;
import com.pureix.easylocator.model.bean.CustomSettingsLocation;
import com.pureix.easylocator.service.batteryService.listener.BatteryReceiverListener;
import com.pureix.easylocator.service.activityRecognitionService.listener.ActivityRecognitionListener;
@@ -24,12 +25,17 @@ import com.pureix.easylocator.service.internetService.listener.ConnectivityRecei
import com.pureix.easylocator.service.locatonService.Listener.LocationReceiverListener;
import java.util.ArrayList;
+import java.util.Observable;
+import java.util.Observer;
+
+import static com.pureix.easylocator.service.batteryService.broadcastReceiver.BatteryAppSideBroadcast.batteryChangedObservable;
public class MainActivity extends AppCompatActivity {
private TextView txt;
private LocationAPI locationAPI;
private ActivityRecognitionAPI activityRecognitionAPI;
+ private BatteryAPI batteryAPI;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -39,6 +45,7 @@ public class MainActivity extends AppCompatActivity {
setSupportActionBar(toolbar);
txt = (TextView) findViewById(R.id.txt);
+
activityRecognitionAPI = new ActivityRecognitionAPI(MainActivity.this);
activityRecognitionAPI.setActivitiesRecognitionListener(new ActivityRecognitionListener()
{
@@ -63,16 +70,18 @@ public class MainActivity extends AppCompatActivity {
}
});
- BatteryAPI.start(MainActivity.this);
- BatteryAPI.batteryListener(new BatteryReceiverListener() {
+ batteryAPI = new BatteryAPI(MainActivity.this);
+
+ batteryAPI.batteryListener(new BatteryReceiverListener() {
@Override
- public void onBatteryInformationChanged(int level, int scale, int temperature, int voltage, float batteryPct, int status, boolean isCharging, int chargePlug, boolean usbCharge, boolean acCharge) {
- txt.append("level is " + level + "/" + scale +
- ", temp is " + temperature +
- ", voltage is " + voltage
- + " status :" + status +
- " chargePlug :" + chargePlug +
- " Battery Pct : " + batteryPct * 100 +"\n\n");
+ public void onBatteryInformationChanged(BatteryInformation batteryInformation) {
+ txt.append("level is " + batteryInformation.getLevel()
+ + "/" + batteryInformation.getScale() +
+ ", temp is " + batteryInformation.getTemperature() +
+ ", voltage is " + batteryInformation.getTemperature()
+ + " status :" + batteryInformation.getStatus() +
+ " chargePlug :" + batteryInformation.getChargePlug() +
+ " Battery Pct : " + batteryInformation.getBatteryPct() * 100 +"\n\n");
}
});
@@ -101,12 +110,12 @@ public class MainActivity extends AppCompatActivity {
smartLocationAPI.setLocationReceiverListener(new LocationReceiverListener() {
@Override
public void getLastKnownLocation(Location location) {
-
+ txt.append("Smart getLastKnownLocation "+location+"\n\n");
}
@Override
public void onLocationChanged(Location location) {
-
+ txt.append("Smart onLocationChanged "+location+"\n\n");
}
});
@@ -150,6 +159,7 @@ public class MainActivity extends AppCompatActivity {
super.onResume();
activityRecognitionAPI.start();
locationAPI.start();
+ batteryAPI.start();
}
@Override
@@ -157,6 +167,7 @@ public class MainActivity extends AppCompatActivity {
super.onPause();
activityRecognitionAPI.pause();
locationAPI.pause();
+ batteryAPI.pause();
}
@Override
diff --git a/SampleEasyLocator/build.gradle b/SampleEasyLocator/build.gradle
index 74b2ab0..d0aa704 100644
--- a/SampleEasyLocator/build.gradle
+++ b/SampleEasyLocator/build.gradle
@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.2.3'
+ classpath 'com.android.tools.build:gradle:2.3.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
diff --git a/SampleEasyLocator/easylocator/src/main/AndroidManifest.xml b/SampleEasyLocator/easylocator/src/main/AndroidManifest.xml
index 2c64fa3..711fabf 100644
--- a/SampleEasyLocator/easylocator/src/main/AndroidManifest.xml
+++ b/SampleEasyLocator/easylocator/src/main/AndroidManifest.xml
@@ -69,6 +69,15 @@
+
+
+
+
+
+
aClass;
+ private Intent intent;
+
+ public BatteryInformationSender(Context context, Class> aClass)
+ {
+ this.context = context;
+ this.aClass = aClass;
+ this.intent = new Intent(context, aClass);
+ }
+
+ public Intent getIntent() {
+ return intent;
+ }
+
+
+ public void sendBatteryInformationToApp(String jsonLocation)
+ {
+ intent.putExtra(BatteryServicesConstant.SERVICE_ID , BatteryServicesConstant
+ .SERVICE_ID_SEND_JSON_BATTERY_INFORMATION);
+ intent.putExtra(BatteryServicesConstant.JSON_BATTERY_INFORMATION , jsonLocation);
+
+ context.sendBroadcast(intent);
+ }
+}
diff --git a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/batteryService/broadcastReceiver/BatteryStateReceiver.java b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/batteryService/broadcastReceiver/BatteryStateReceiver.java
index 7533177..c5b5b6f 100644
--- a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/batteryService/broadcastReceiver/BatteryStateReceiver.java
+++ b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/batteryService/broadcastReceiver/BatteryStateReceiver.java
@@ -3,18 +3,18 @@ package com.pureix.easylocator.service.batteryService.broadcastReceiver;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
-import android.content.IntentFilter;
import android.os.BatteryManager;
-import android.widget.Toast;
-import com.pureix.easylocator.service.batteryService.listener.BatteryReceiverListener;
+import com.google.gson.Gson;
+import com.pureix.easylocator.service.batteryService.bean.BatteryInformation;
-import static com.pureix.easylocator.controller.service.BatteryAPI.batteryReceiverListener;
public class BatteryStateReceiver extends BroadcastReceiver
{
//private static Context context;
+// public static ObservableHandler batteryChangedObservable = new ObservableHandler();
+
private static Boolean batteryReceiverIsRegistered = false;
@@ -47,6 +47,8 @@ public class BatteryStateReceiver extends BroadcastReceiver
@Override
public void onReceive(Context context, Intent intent)
{
+ BatteryInformationSender senderHandler = new BatteryInformationSender(context, BatteryAppSideBroadcast.class);
+
int level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
int scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
int temperature = intent.getIntExtra(BatteryManager.EXTRA_TEMPERATURE, -1);
@@ -67,11 +69,18 @@ public class BatteryStateReceiver extends BroadcastReceiver
if(!(level == -1 && scale == -1 && temperature == -1 && voltage == -1
&& status == -1 && chargePlug == -1)) {
- if(batteryReceiverListener != null) {
+ /*if(batteryReceiverListener != null) {
batteryReceiverListener.onBatteryInformationChanged(level, scale,
temperature, voltage, batteryPct, status, isCharging,
chargePlug, usbCharge, acCharge);
- }
+ }*/
+ BatteryInformation batteryInformation = new BatteryInformation(level,
+ scale, temperature, voltage, batteryPct, status, isCharging,
+ chargePlug, usbCharge, acCharge);
+
+ sendBatteryInformationToBroadcast(senderHandler, batteryInformation);
+
+
// Toast.makeText(context,
// "level is " + level + "/" + scale +
// ", temp is " + temperature +
@@ -82,4 +91,11 @@ public class BatteryStateReceiver extends BroadcastReceiver
// Toast.LENGTH_SHORT).show();
}
}
+
+ private void sendBatteryInformationToBroadcast(BatteryInformationSender senderHandler,
+ BatteryInformation batteryInformation) {
+ senderHandler
+ .sendBatteryInformationToApp(new Gson()
+ .toJson(batteryInformation));
+ }
}
diff --git a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/batteryService/broadcastReceiver/InitializeBatteryBroadcast.java b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/batteryService/broadcastReceiver/InitializeBatteryBroadcast.java
index b7fc18c..56add34 100644
--- a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/batteryService/broadcastReceiver/InitializeBatteryBroadcast.java
+++ b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/batteryService/broadcastReceiver/InitializeBatteryBroadcast.java
@@ -14,7 +14,7 @@ import com.pureix.easylocator.service.activityRecognitionService.broadcastReceiv
public class InitializeBatteryBroadcast
{
- private static BatteryStateReceiver broadcastReceiver = null;
+ private static BatteryStateReceiver broadcastReceiver = null;
private static Boolean isRegistered = false;
public InitializeBatteryBroadcast() {
diff --git a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/batteryService/broadcastReceiver/InitializeBatteryFromAppBroadcast.java b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/batteryService/broadcastReceiver/InitializeBatteryFromAppBroadcast.java
new file mode 100644
index 0000000..65a2314
--- /dev/null
+++ b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/batteryService/broadcastReceiver/InitializeBatteryFromAppBroadcast.java
@@ -0,0 +1,61 @@
+package com.pureix.easylocator.service.batteryService.broadcastReceiver;
+
+import android.app.Activity;
+import android.app.ActivityManager;
+import android.content.Context;
+import android.content.IntentFilter;
+
+/**
+ * Created by MelDiSooQi on 1/28/2017.
+ */
+
+public class InitializeBatteryFromAppBroadcast
+{
+ private static BatteryAppSideBroadcast broadcastReceiverFromApp = null;
+ private static Boolean isRegistered = false;
+
+ public InitializeBatteryFromAppBroadcast() {
+ initialize();
+ }
+
+ private void initialize()
+ {
+ broadcastReceiverFromApp = new BatteryAppSideBroadcast();
+ }
+
+ public void onPause(Context context)
+ {
+ try {
+ if (isRegistered) {
+ context.unregisterReceiver(broadcastReceiverFromApp);
+ isRegistered = false;
+ }
+ }catch (Exception e)
+ {}
+ }
+
+ public void onResume(Context context)
+ {
+ if (!isRegistered)
+ {
+ IntentFilter filter = new IntentFilter("com.pureix.easylocator.service.batteryService.broadcastReceiver.BatteryAppSideBroadcast");
+ context.registerReceiver(broadcastReceiverFromApp, filter);
+
+ isRegistered = true;
+ }
+ }
+
+ public static boolean isMyServiceRunning(Activity activity, Class> serviceClass)
+ {
+ ActivityManager manager = (ActivityManager) activity
+ .getSystemService(Context.ACTIVITY_SERVICE);
+ for (ActivityManager.RunningServiceInfo service : manager
+ .getRunningServices(Integer.MAX_VALUE)) {
+ if (serviceClass.getName().equals(service.service.getClassName())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
diff --git a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/batteryService/listener/BatteryReceiverListener.java b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/batteryService/listener/BatteryReceiverListener.java
index 46ff19e..5adde6e 100644
--- a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/batteryService/listener/BatteryReceiverListener.java
+++ b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/batteryService/listener/BatteryReceiverListener.java
@@ -1,13 +1,17 @@
package com.pureix.easylocator.service.batteryService.listener;
+import com.pureix.easylocator.service.batteryService.bean.BatteryInformation;
+
/**
* Created by MelDiSooQi on 1/27/2017.
*/
public interface BatteryReceiverListener
{
- void onBatteryInformationChanged(int level, int scale, int temperature,
+ /*void onBatteryInformationChanged(int level, int scale, int temperature,
int voltage, float batteryPct, int status,
boolean isCharging, int chargePlug,
- boolean usbCharge, boolean acCharge);
+ boolean usbCharge, boolean acCharge);*/
+
+ void onBatteryInformationChanged(BatteryInformation batteryInformation);
}
diff --git a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/LocationService.java b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/LocationService.java
index 0d8ba9e..61dbd1e 100644
--- a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/LocationService.java
+++ b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/LocationService.java
@@ -12,7 +12,6 @@ import android.os.PowerManager;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.Log;
-import android.widget.Toast;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GoogleApiAvailability;
@@ -25,18 +24,12 @@ import com.google.gson.Gson;
import com.pureix.easylocator.model.bean.CustomSettingsLocation;
import com.pureix.easylocator.model.storage.LocalStorage;
import com.pureix.easylocator.model.storage.LocalStorageConstant;
-import com.pureix.easylocator.service.locatonService.Listener.LocationReceiverListener;
import com.pureix.easylocator.service.locatonService.broadcastReceiver.LocationBroadcast;
import com.pureix.easylocator.service.locatonService.broadcastReceiver.LocationSender;
-import java.util.Observable;
-import java.util.Observer;
-import java.util.Random;
import java.util.Timer;
import java.util.TimerTask;
-import static com.pureix.easylocator.service.SmartLocationBusiness.smartLocationBusinessObservable;
-
/**
* Created by MelDiSooQi on 1/28/2017.
*/
@@ -64,7 +57,9 @@ public class LocationService extends Service implements
private final static int PLAY_SERVICES_RESOLUTION_REQUEST = 9000;
private GoogleApiClient mGoogleApiClient;
- private LocationReceiverListener locationReceiverListener;
+ private CustomSettingsLocation customSettingsLocation;
+
+ //private LocationReceiverListener locationReceiverListener;
/**
* Class used for the client Binder. Because we know this service always
@@ -83,11 +78,21 @@ public class LocationService extends Service implements
return mBinder;
}
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ Log.e(TAG, "onCreate");
+ context = getApplicationContext();
+ }
+
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
super.onStartCommand(intent, flags, startId);
Log.e(TAG, "onStartCommand");
+ getIntentExtrasData(intent);
+ asOnCreate();
+
PowerManager mgr = (PowerManager) getSystemService(Context.POWER_SERVICE);
/*
@@ -116,26 +121,62 @@ public class LocationService extends Service implements
return START_STICKY;
}
- @Override
- public void onCreate() {
- super.onCreate();
- Log.e(TAG, "onCreate");
- context = getApplicationContext();
+ private void getIntentExtrasData(Intent intent) {
+ if(intent != null) {
+ Bundle extras = intent.getExtras();
+ if (extras != null) {
+ String jsonCustomSettingsLocation = extras.getString(LocationServicesConstant.CUSTOM_SETTINGS_LOCATION);
- senderHandler = new LocationSender(context,
- LocationBroadcast.class);
+ customSettingsLocation = new Gson()
+ .fromJson(jsonCustomSettingsLocation, CustomSettingsLocation.class);
+ }
+ }
+
+ if(customSettingsLocation == null)
+ {
+ createCustomSettingsLocation();
+ }
+ }
+
+ private CustomSettingsLocation createCustomSettingsLocation() {
+ customSettingsLocation = new CustomSettingsLocation();
+
+ customSettingsLocation.setDetectedActivityType(-1);
+ customSettingsLocation.setDetectedActivityProvider("Normal");
+
+ customSettingsLocation.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
+ customSettingsLocation.setInterval(Constants.UPDATE_INTERVAL);
+ customSettingsLocation.setFastestInterval(Constants.FASTEST_INTERVAL);
+ customSettingsLocation.setSmallestDisplacement(0);
+
+ return customSettingsLocation;
+ }
+
+ private void asOnCreate(){
+
+ senderHandler = new LocationSender(context, LocationBroadcast.class);
mInProgress = false;
// Create the LocationRequest object
mLocationRequest = LocationRequest.create();
+
// Use high accuracy
- mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
+ mLocationRequest.setPriority(customSettingsLocation.getPriority());
// Set the update interval to 5 seconds
- mLocationRequest.setInterval(Constants.UPDATE_INTERVAL);
+ mLocationRequest.setInterval(customSettingsLocation.getInterval());
+ // Set the fastest update interval to 1 second
+ mLocationRequest.setFastestInterval(customSettingsLocation.getFastestInterval());
+ //update the location every some distance
+ mLocationRequest.setSmallestDisplacement(customSettingsLocation.getSmallestDisplacement());
+
+ // Use high accuracy
+ //mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
+ // Set the update interval to 5 seconds
+ //mLocationRequest.setInterval(Constants.UPDATE_INTERVAL);
// mLocationRequest.setInterval(1000);
// Set the fastest update interval to 1 second
// mLocationRequest.setFastestInterval(1000);
- mLocationRequest.setFastestInterval(Constants.FASTEST_INTERVAL);
+ //mLocationRequest.setFastestInterval(Constants.FASTEST_INTERVAL);
//update the location every some distance
//mLocationRequest.setSmallestDisplacement(10);
@@ -260,10 +301,10 @@ public class LocationService extends Service implements
try {
Location location = getLastLocation();
sendLocationToBroadcast(location);
- if(locationReceiverListener !=null) {
+ /*if(locationReceiverListener !=null) {
locationReceiverListener.getLastKnownLocation(location);
// locationReceiverListener.onLocationChanged(location);
- }
+ }*/
} catch (Exception e) {
}
// Request location updates using static settings
@@ -448,9 +489,9 @@ public class LocationService extends Service implements
}
sendLocationToBroadcast(location);
- if(locationReceiverListener != null) {
- locationReceiverListener.onLocationChanged(location);
- }
+// if(locationReceiverListener != null) {
+// locationReceiverListener.onLocationChanged(location);
+// }
}
private CustomSettingsLocation getCustomSettingsLocationInLocalStorage() {
diff --git a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/ServicesConstant.java b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/LocationServicesConstant.java
similarity index 90%
rename from SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/ServicesConstant.java
rename to SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/LocationServicesConstant.java
index 698f93b..17394f8 100644
--- a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/ServicesConstant.java
+++ b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/LocationServicesConstant.java
@@ -3,7 +3,7 @@ package com.pureix.easylocator.service.locatonService;
/**
* Created by M.Hayle on 6/29/2016.
*/
-public class ServicesConstant
+public class LocationServicesConstant
{
//==========================S Location Service=================================
public final static String SERVICE_ID = "SERVICE_ID";
@@ -23,4 +23,6 @@ public class ServicesConstant
public final static String BEARING = "BEARING";
public final static String SPEED = "SPEED";
//==========================E Location Service=================================
+
+ public final static String CUSTOM_SETTINGS_LOCATION = "CUSTOM_SETTINGS_LOCATION";
}
diff --git a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/broadcastReceiver/LocationBroadcast.java b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/broadcastReceiver/LocationBroadcast.java
index 7b2cdf1..0b340ff 100644
--- a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/broadcastReceiver/LocationBroadcast.java
+++ b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/broadcastReceiver/LocationBroadcast.java
@@ -8,8 +8,7 @@ import android.widget.Toast;
import com.google.gson.Gson;
import com.pureix.easylocator.model.ObservableHandler;
-import com.pureix.easylocator.service.locatonService.Listener.LocationReceiverListener;
-import com.pureix.easylocator.service.locatonService.ServicesConstant;
+import com.pureix.easylocator.service.locatonService.LocationServicesConstant;
import com.pureix.easylocator.service.locatonService.bean.Location;
public class LocationBroadcast extends BroadcastReceiver
@@ -25,19 +24,20 @@ public class LocationBroadcast extends BroadcastReceiver
@Override
public void onReceive(Context context, Intent intent) {
Bundle extras = intent.getExtras();
- if(extras.getInt(ServicesConstant.SERVICE_ID) == ServicesConstant.SERVICE_ID_SEND_LOCATION)
+ if(extras.getInt(LocationServicesConstant.SERVICE_ID) ==
+ LocationServicesConstant.SERVICE_ID_SEND_LOCATION)
{
Location location;
- int USER_ID = extras.getInt (ServicesConstant.USER_ID);
- double latitude = extras.getDouble(ServicesConstant.LATITUDE);
- double longitude = extras.getDouble(ServicesConstant.LONGITUDE);
- String locationProvider = extras.getString(ServicesConstant.LOCATION_PROVIDER);
- Float accuracy = extras.getFloat(ServicesConstant.ACCURACY);
- long time = extras.getLong(ServicesConstant.TIME);
- double altitude = extras.getDouble(ServicesConstant.ALTITUDE);
- float bearing = extras.getFloat(ServicesConstant.BEARING);
- float speed = extras.getFloat(ServicesConstant.SPEED);
+ int USER_ID = extras.getInt (LocationServicesConstant.USER_ID);
+ double latitude = extras.getDouble(LocationServicesConstant.LATITUDE);
+ double longitude = extras.getDouble(LocationServicesConstant.LONGITUDE);
+ String locationProvider = extras.getString(LocationServicesConstant.LOCATION_PROVIDER);
+ Float accuracy = extras.getFloat(LocationServicesConstant.ACCURACY);
+ long time = extras.getLong(LocationServicesConstant.TIME);
+ double altitude = extras.getDouble(LocationServicesConstant.ALTITUDE);
+ float bearing = extras.getFloat(LocationServicesConstant.BEARING);
+ float speed = extras.getFloat(LocationServicesConstant.SPEED);
if(!isLocationInitialized) {
@@ -58,9 +58,10 @@ public class LocationBroadcast extends BroadcastReceiver
+" USER_ID "+USER_ID;
Toast.makeText(context, "From BroadCast : "+s, Toast.LENGTH_SHORT).show();
// LoggerAndToastHandler.PrintToastMsg(s);
- }else if(extras.getInt(ServicesConstant.SERVICE_ID) == ServicesConstant.SERVICE_ID_SEND_JSON_LOCATION)
+ }else if(extras.getInt(LocationServicesConstant.SERVICE_ID) ==
+ LocationServicesConstant.SERVICE_ID_SEND_JSON_LOCATION)
{
- String jsonLocation = extras.getString(ServicesConstant.JSON_LOCATION);
+ String jsonLocation = extras.getString(LocationServicesConstant.JSON_LOCATION);
android.location.Location location = new Gson()
.fromJson(jsonLocation, android.location.Location.class);
@@ -82,7 +83,7 @@ public class LocationBroadcast extends BroadcastReceiver
+" speed "+ kMeter
+" accuracy "+location.getAccuracy();
- //Toast.makeText(context, "AFrom BroadCast : "+s, Toast.LENGTH_SHORT).show();
+// Toast.makeText(context, "AFrom BroadCast : "+s, Toast.LENGTH_SHORT).show();
}
}
}
diff --git a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/broadcastReceiver/LocationSender.java b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/broadcastReceiver/LocationSender.java
index 159eb7c..cadd5ff 100644
--- a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/broadcastReceiver/LocationSender.java
+++ b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/broadcastReceiver/LocationSender.java
@@ -3,7 +3,7 @@ package com.pureix.easylocator.service.locatonService.broadcastReceiver;
import android.content.Context;
import android.content.Intent;
-import com.pureix.easylocator.service.locatonService.ServicesConstant;
+import com.pureix.easylocator.service.locatonService.LocationServicesConstant;
/**
* Created by MelDiSooQi on 7/16/2016.
@@ -28,13 +28,13 @@ public class LocationSender
/*
public void sendLocationToApp(int userID, double latitude, double longitude, String provider, float accuracy, long time)
{
- intent.putExtra(ServicesConstant.SERVICE_ID , ServicesConstant.SERVICE_ID_SEND_LOCATION);
- intent.putExtra(ServicesConstant.USER_ID , userID);
- intent.putExtra(ServicesConstant.LATITUDE , latitude);
- intent.putExtra(ServicesConstant.LONGITUDE , longitude);
- intent.putExtra(ServicesConstant.LOCATION_PROVIDER , provider);
- intent.putExtra(ServicesConstant.ACCURACY , accuracy);
- intent.putExtra(ServicesConstant.TIME , time);
+ intent.putExtra(LocationServicesConstant.SERVICE_ID , LocationServicesConstant.SERVICE_ID_SEND_LOCATION);
+ intent.putExtra(LocationServicesConstant.USER_ID , userID);
+ intent.putExtra(LocationServicesConstant.LATITUDE , latitude);
+ intent.putExtra(LocationServicesConstant.LONGITUDE , longitude);
+ intent.putExtra(LocationServicesConstant.LOCATION_PROVIDER , provider);
+ intent.putExtra(LocationServicesConstant.ACCURACY , accuracy);
+ intent.putExtra(LocationServicesConstant.TIME , time);
context.sendBroadcast(intent);
}
@@ -42,56 +42,56 @@ public class LocationSender
public void sendLocationToApp(int userID, double latitude, double longitude, String provider, float accuracy, long time, double altitude, float bearing, float speed)
{
- intent.putExtra(ServicesConstant.SERVICE_ID , ServicesConstant.SERVICE_ID_SEND_LOCATION);
- intent.putExtra(ServicesConstant.USER_ID , userID);
- intent.putExtra(ServicesConstant.LATITUDE , latitude);
- intent.putExtra(ServicesConstant.LONGITUDE , longitude);
- intent.putExtra(ServicesConstant.LOCATION_PROVIDER , provider);
- intent.putExtra(ServicesConstant.ACCURACY , accuracy);
- intent.putExtra(ServicesConstant.TIME , time);
- intent.putExtra(ServicesConstant.ALTITUDE , altitude);
- intent.putExtra(ServicesConstant.BEARING , bearing);
- intent.putExtra(ServicesConstant.SPEED , speed);
+ intent.putExtra(LocationServicesConstant.SERVICE_ID , LocationServicesConstant.SERVICE_ID_SEND_LOCATION);
+ intent.putExtra(LocationServicesConstant.USER_ID , userID);
+ intent.putExtra(LocationServicesConstant.LATITUDE , latitude);
+ intent.putExtra(LocationServicesConstant.LONGITUDE , longitude);
+ intent.putExtra(LocationServicesConstant.LOCATION_PROVIDER , provider);
+ intent.putExtra(LocationServicesConstant.ACCURACY , accuracy);
+ intent.putExtra(LocationServicesConstant.TIME , time);
+ intent.putExtra(LocationServicesConstant.ALTITUDE , altitude);
+ intent.putExtra(LocationServicesConstant.BEARING , bearing);
+ intent.putExtra(LocationServicesConstant.SPEED , speed);
context.sendBroadcast(intent);
}
public void sendLocationToApp(String userID, double latitude, double longitude, String provider, float accuracy, long time, double altitude, float bearing, float speed)
{
- intent.putExtra(ServicesConstant.SERVICE_ID , ServicesConstant.SERVICE_ID_SEND_LOCATION);
- intent.putExtra(ServicesConstant.USER_ID , userID);
- intent.putExtra(ServicesConstant.LATITUDE , latitude);
- intent.putExtra(ServicesConstant.LONGITUDE , longitude);
- intent.putExtra(ServicesConstant.LOCATION_PROVIDER , provider);
- intent.putExtra(ServicesConstant.ACCURACY , accuracy);
- intent.putExtra(ServicesConstant.TIME , time);
- intent.putExtra(ServicesConstant.ALTITUDE , altitude);
- intent.putExtra(ServicesConstant.BEARING , bearing);
- intent.putExtra(ServicesConstant.SPEED , speed);
+ intent.putExtra(LocationServicesConstant.SERVICE_ID , LocationServicesConstant.SERVICE_ID_SEND_LOCATION);
+ intent.putExtra(LocationServicesConstant.USER_ID , userID);
+ intent.putExtra(LocationServicesConstant.LATITUDE , latitude);
+ intent.putExtra(LocationServicesConstant.LONGITUDE , longitude);
+ intent.putExtra(LocationServicesConstant.LOCATION_PROVIDER , provider);
+ intent.putExtra(LocationServicesConstant.ACCURACY , accuracy);
+ intent.putExtra(LocationServicesConstant.TIME , time);
+ intent.putExtra(LocationServicesConstant.ALTITUDE , altitude);
+ intent.putExtra(LocationServicesConstant.BEARING , bearing);
+ intent.putExtra(LocationServicesConstant.SPEED , speed);
context.sendBroadcast(intent);
}
public void sendLocationToApp(double latitude, double longitude, String provider, float accuracy, long time, double altitude, float bearing, float speed)
{
- intent.putExtra(ServicesConstant.SERVICE_ID , ServicesConstant.SERVICE_ID_SEND_LOCATION);
- intent.putExtra(ServicesConstant.LATITUDE , latitude);
- intent.putExtra(ServicesConstant.LONGITUDE , longitude);
- intent.putExtra(ServicesConstant.LOCATION_PROVIDER , provider);
- intent.putExtra(ServicesConstant.ACCURACY , accuracy);
- intent.putExtra(ServicesConstant.TIME , time);
- intent.putExtra(ServicesConstant.ALTITUDE , altitude);
- intent.putExtra(ServicesConstant.BEARING , bearing);
- intent.putExtra(ServicesConstant.SPEED , speed);
+ intent.putExtra(LocationServicesConstant.SERVICE_ID , LocationServicesConstant.SERVICE_ID_SEND_LOCATION);
+ intent.putExtra(LocationServicesConstant.LATITUDE , latitude);
+ intent.putExtra(LocationServicesConstant.LONGITUDE , longitude);
+ intent.putExtra(LocationServicesConstant.LOCATION_PROVIDER , provider);
+ intent.putExtra(LocationServicesConstant.ACCURACY , accuracy);
+ intent.putExtra(LocationServicesConstant.TIME , time);
+ intent.putExtra(LocationServicesConstant.ALTITUDE , altitude);
+ intent.putExtra(LocationServicesConstant.BEARING , bearing);
+ intent.putExtra(LocationServicesConstant.SPEED , speed);
context.sendBroadcast(intent);
}
public void sendLocationToApp(String jsonLocation)
{
- intent.putExtra(ServicesConstant.SERVICE_ID , ServicesConstant
+ intent.putExtra(LocationServicesConstant.SERVICE_ID , LocationServicesConstant
.SERVICE_ID_SEND_JSON_LOCATION);
- intent.putExtra(ServicesConstant.JSON_LOCATION , jsonLocation);
+ intent.putExtra(LocationServicesConstant.JSON_LOCATION , jsonLocation);
context.sendBroadcast(intent);
}
diff --git a/SampleEasyLocator/gradle/wrapper/gradle-wrapper.properties b/SampleEasyLocator/gradle/wrapper/gradle-wrapper.properties
index 04e285f..f6ffcb6 100644
--- a/SampleEasyLocator/gradle/wrapper/gradle-wrapper.properties
+++ b/SampleEasyLocator/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Mon Dec 28 10:00:20 PST 2015
+#Thu May 18 20:32:27 EET 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip