VersCreativeUK / FACETS

An open tracker repository for the development team to manage the FACETS project.
0 stars 0 forks source link

[ISSUE] GPS Issues (Activity Diary Additional Information) #24

Closed davcpas1234 closed 5 years ago

davcpas1234 commented 5 years ago

Application Version

0.0.5

Issue Description

When retrieving location, the application hangs on "Getting Location..." and doesn't propagate past this. The only way to exit is user interaction.

Steps to Reproduce

  1. Go to Activity Diary
  2. Click on '+'
  3. Add Activity Details
  4. Click on 'Additional Information'
  5. Select 'Outside Temperature'
  6. Hangs Here

Expected Behaviour

Location is retrieved and weather API call is performed, temperature is retrieved.

davcpas1234 commented 5 years ago

After investigation, this issue cannot be replicated on any simulated devices, but is reflected on all live devices.

davcpas1234 commented 5 years ago

New Implementation:

[...]
if(context != null) {
    locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
    locationListener = new LocationListener() {
        @Override
        public void onLocationChanged(Location location) {
            if(locationProgress != null) {
                locationProgress.dismiss();
            }
            mLocation = location;
            Log.d("Location Changes", location.toString());
            setTemperatureValue(mLocation);
        }

        @Override
        public void onStatusChanged(String provider, int status, Bundle extras) {
            Log.d("Status Changed", String.valueOf(status));
        }

        @Override
        public void onProviderEnabled(String provider) {
            Log.d("Provider Enabled", provider);
        }

        @Override
        public void onProviderDisabled(String provider) {
            Log.d("Provider Disabled", provider);
        }
    };

    criteria = new Criteria();
    criteria.setAccuracy(Criteria.ACCURACY_COARSE);
    criteria.setPowerRequirement(Criteria.POWER_LOW);
    criteria.setAltitudeRequired(false);
    criteria.setBearingRequired(false);
    criteria.setSpeedRequired(false);
    criteria.setCostAllowed(false);
    criteria.setHorizontalAccuracy(Criteria.ACCURACY_HIGH);
    criteria.setVerticalAccuracy(Criteria.ACCURACY_HIGH);

    mLooper = null;

}
[...]
int coarseLocationPermission = PermissionChecker.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION);
int fineLocationPermission = PermissionChecker.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION);

if (coarseLocationPermission == PermissionChecker.PERMISSION_GRANTED && fineLocationPermission == PermissionChecker.PERMISSION_GRANTED) {
    locationManager.requestSingleUpdate(criteria, locationListener, mLooper);
} else {
    ((MainActivity) getActivity()).createAndCheckPermissions();
}
[...]
davcpas1234 commented 5 years ago

New implementation has been successful in testing:

issue-24

This will be released as part of v0.0.6-rc4