0% found this document useful (0 votes)
15 views3 pages

Permissions

This document provides instructions for a lab on declaring and using permissions in an Android application. The lab involves creating an app called PermissionsLab that dials a hardcoded phone number when the user clicks a floating action button. It describes testing the app by rejecting the phone permission request, accepting it, and verifying the number is dialed. Developers are told to only modify marked areas and test on an emulator like a Pixel 5 to limit configuration problems.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views3 pages

Permissions

This document provides instructions for a lab on declaring and using permissions in an Android application. The lab involves creating an app called PermissionsLab that dials a hardcoded phone number when the user clicks a floating action button. It describes testing the app by rejecting the phone permission request, accepting it, and verifying the number is dialed. Developers are told to only modify marked areas and test on an emulator like a Pixel 5 to limit configuration problems.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Laboratory – Permissions

Learn how to declare permissions so that your app can access restricted services

Objectives:
Familiarize yourself with declaring a permission and using that permission in order to dial a
phone number (which is a permission-protected action). Create a simple application that dials
a hard-coded phone number. Once you’ve completed this Lab you should understand how to
declare that your app uses a given permission, how to ask users to grant that permission, and
how to invoke a permission-protected action.

PermissionsLab
This lab involves an app called PermissionsLab. When it runs, the app displays a user interface like the
one shown below.

When the user clicks on the floating action button with the phone icon (fab), this application will
initiate a phone call to a fixed phone number (without requiring the user to dial the phone number).
This behavior is shown in the screenshot below.

1
See the screencast, LabPermissions.mp4, that's included in the Lab directory.

Testing
After completing your solution, you will record a screencast of your app as you perform a
manual test. Afterward, you will submit your code and the screencast via git. Put your
screencast in the lab directory.

There is one test case with several evaluation points. This test case operates as follows:

1. Ensure that PermissionsLab app is uninstalled on device


2. Start the PermissionsLab app from the IDE
3. Click on the fab
4. When the permissions request dialog appears, reject the request.
5. Check that a pop up appears explaining the need for the permission (evaluation point
1)
6. Click on the fab
7. When the “Snackbar” pops up click “ok”
8. Click again on the fab
9. When the permissions request dialog appears, accept the request.
10. Check that device initiates a phone call to the hardcoded number (evaluation point 2)

Some Implementation Notes

We are providing template code and layout resources for this application. Only modify the areas
marked with the word TODO.
2
We have done our testing on an emulator using a Pixel 5 AVD with API level 31. To limit configuration
problems, you should test your app against a similar AVD.

Note that once you accept the permission, the app won’t ask again. Similarly, if you reject the
permission twice, the app won’t ask again. To reset the permission requesting behavior, you may need
to uninstall and then reinstall the app. You can uninstall by finding the PermissionsLab icon on the
home screen; long clicking it, clicking on “App Info,” and then clicking on “uninstall.”

You might also like