O'Reilly logo

Android Programming: The Big Nerd Ranch Guide, Third Edition by Kristin Marsicano, Chris Stewart, Bill Phillips

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Asking for Permission at Runtime

Handling permissions at runtime requires you to do three things:

  • check to see whether you have permission before performing the operation

  • request permission if you do not already have it

  • listen for the response to your permissions request

Requesting permission means displaying the system-standard permissions request UI. If this dialog pops up in a place in your app where it is clear why you are asking your user for this permission, then this is all you need to do.

Sometimes, though, the reason is not obvious. Users often deny requests that do not make sense to them, so in those cases you will need to display a rationale. So those apps require a fourth step:

  • check to see whether you need ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required