Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. @TargetApi(23)
  2. public boolean checkLocationPermission() {
  3. boolean granted = false;
  4. if (getContext().checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
  5. requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_CODE_LOCATION);
  6. Toast.makeText(getContext(), R.string.check_permission_location_information, Toast.LENGTH_SHORT).show();
  7. if (getContext().checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
  8. granted = true;
  9. }
  10. } else {
  11. granted = true;
  12. }
  13. return granted;
  14. }
  15.  
  16. @OnClick(R.id.btn_refresh_events)
  17. public void onRefreshClick() {
  18. boolean isPermissionGranted = checkLocationPermission();
  19. if (isPermissionGranted) {
  20. refreshingEvents.setVisibility(View.GONE);
  21. mPresenter.refresh();
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement