Skip to content

Commit

Permalink
Fix permission requests on Marshmallow.
Browse files Browse the repository at this point in the history
  • Loading branch information
cghamblett committed Dec 3, 2015
1 parent 3e5a1dc commit db54dd1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions app/src/main/java/org/opus/beacon/MapActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,21 +121,21 @@ private void setUpMap() {

mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

requestGPSUpdates();
}

private void requestGPSUpdates() {
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) !=
PackageManager.PERMISSION_GRANTED) {

ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
ACCESS_FINE_LOCATION_TAG);
} else {
requestGPSUpdates();
mLocationManager.requestLocationUpdates(mLocationManager.GPS_PROVIDER, 1000, 1, this);
}
}

private void requestGPSUpdates() {
mLocationManager.requestLocationUpdates(mLocationManager.GPS_PROVIDER, 1000, 1, this);
}

public void toastError(String err) {
Toast toast = Toast.makeText(context, err, Toast.LENGTH_SHORT);
TextView v = (TextView) toast.getView().findViewById(android.R.id.message);
Expand Down

0 comments on commit db54dd1

Please sign in to comment.