-2

When I call the getLastKnownLocation () method I get an error "Java Android call requires permission which may be rejected by user...". Apparently it's due to API23. I can't find a valid solution yet.

DataCube
  • 107
  • 1
  • 1
  • 10

2 Answers2

0

You can use shouldShowRequestPermissionRationale() to check if you need to show the reason why you need this permission (and if it returns true - show the reason), and, of course, you need to request permissions with requestPermissions() method.

Ksenia
  • 3,453
  • 7
  • 31
  • 63
0

So, you can't do anything if user rejected the permission. It is meant to give error if user reject the request. You can do one thing if user deny then give a dialog to user asking to accept it otherwise the functionality will not work and redirect him to that permission dialog.