Step #2: Requesting a Permission

Our app will be working directly with the Internet. For that, we need permission from the user.

Requesting permissions from the user starts with a <uses-permission> element in the manifest, identifying what it is that we want. For some permissions — those deemed to be “dangerous” — we also need to prompt the user at runtime to confirm whether they do indeed want to grant us this permission.

The permission that we need for Internet access — android.permission.INTERNET — is not a dangerous permission. So, all we need is the <uses-permission> element.

So, add this element as a child of the root <manifest> element in AndroidManifest.xml:

  <uses-permission android:name="android.permission.INTERNET" />

Prev Table of Contents Next

This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.