Asking the User for Permission

You wouldn’t let your next-door neighbor store holiday decorations in your shed without permission, would you? Probably not. Android is no different. Performing some actions on a user’s Android device requires permission, as explained in the following sections.

Seeing how permissions affect the user experience

When a user installs an application from the Google Play Store, the application’s manifest file is inspected for required permissions. Anytime your application needs access to sensitive components (such as external storage, the Internet, or device information), the user is notified and decides whether to continue the installation.

remember.eps Don’t request unnecessary permissions for your app — security-savvy users are likely to reject it. For example, the Silent Mode Toggle application (described in Part II) doesn’t need GPS locations, Internet access, or hardware-related information.

If your application doesn’t need a permission, yank it. The fewer number of permissions your application requests, the more likely the user is to install it.

Setting requested permissions in the AndroidManifest.xml file

When you need to request permissions, add them to the AndroidManifest.xml file in your project. You need to add the following permissions to the Task Reminder application:

android.permission.RECEIVE_BOOT_COMPLETED: Allows the application to know when the ...

Get Android Application Development For Dummies, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.