Challenge: Permissions Rationale

As mentioned above, the system permission dialog is not descriptive enough for many applications. In those cases, you need to provide the user with a rationale.

Android has a preferred flow for displaying this rationale. As of this writing, it works as follows:

  1. The first time the user asks, show the system dialog.

  2. Any time the user asks after that, show a dialog with your explanation, then the system dialog again.

  3. If the user requests to deny the permission forever, never show the rationale or the system dialog again.

This may seem a little complicated. Luckily, Android provides a method to help you implement it: ActivityCompat’s shouldShowRequestPermissionRationale(…). shouldShowRequestPermissionRationale(…) will return false before you first request a permission, true after it has initially been denied, and then false if the user chooses to permanently deny the permission.

For this challenge, implement a rationale DialogFragment that displays a short message: Locatr uses location data to find images near you on Flickr. Use shouldShowRequestPermissionRationale(…) to see whether the rationale should be displayed before calling requestPermission(…). If the rationale is displayed, Locatr should wait until it is dismissed by the user to call requestPermission(…). (Hint: You can detect dismissal by overriding DialogFragment.onCancel(…).)

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.190.217.134