Skip to content

Commit

Permalink
Merge pull request #45 from Zameelnm96/master
Browse files Browse the repository at this point in the history
By considering power consumption removed get location update from GPS…
  • Loading branch information
Zameelnm96 authored May 25, 2020
2 parents cb708c9 + 9d452e7 commit 960e41f
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,10 @@ public void onCreate() {
.getSystemService(Context.LOCATION_SERVICE);
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
&& ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, LOCATION_UPDATE_INTERVAL * 1000, 100, mLocationListener);
//locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, LOCATION_UPDATE_INTERVAL * 1000, 100, mLocationListener);
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, LOCATION_UPDATE_INTERVAL * 1000, 100, mLocationListener);
locationManager.requestLocationUpdates(LocationManager.PASSIVE_PROVIDER, LOCATION_UPDATE_INTERVAL * 1000, 100, mLocationListener);
isNetworkProviderEnable = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
isGpsProviderEnable = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
isPassiveProviderEnable = locationManager.isProviderEnabled(LocationManager.PASSIVE_PROVIDER);

return;
}

Expand Down Expand Up @@ -180,7 +178,9 @@ public int onStartCommand(Intent intent, int flags, int startId) {
.build();

startForeground(FOREGROUND_ID, notification);

isNetworkProviderEnable = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
isGpsProviderEnable = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
isPassiveProviderEnable = locationManager.isProviderEnabled(LocationManager.PASSIVE_PROVIDER);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Util.scheduleJobHelper(this);
}
Expand Down Expand Up @@ -252,13 +252,13 @@ public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
longitude = location.getLongitude();
Log.d(TAG, "didRangeBeaconsInRegion NETWORK:\n latitude - " + latitude + " longitude - " + longitude);
}
else if(isGpsProviderEnable ) {
/*else if(isGpsProviderEnable ) {
Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
latitude = location.getLatitude();
longitude = location.getLongitude();
Log.d(TAG, "didRangeBeaconsInRegion GPS:\n latitude - " + latitude + " longitude - " + longitude);
}
}*/
else if(isPassiveProviderEnable){
Location location = locationManager.getLastKnownLocation(LocationManager.PASSIVE_PROVIDER);
latitude = location.getLatitude();
Expand Down

0 comments on commit 960e41f

Please sign in to comment.