Add Permissions to the App Manifest

This section outlines how to add permissions to the App Manifest (AndroidManifest.xml) file. This permission mentioned enables your app to use the internet.

The App Manifest contains crucial information about your app (components such as activities, services, receivers, content providers, intent messages, processes, permissions, APIs, classes, minimum versions and libraries) and communicates this to the Android system to enable Android to run your code.

Our SDK for Android requires Location permissions in order to avail of our geographical insights within the platform. As of Android 6.0 (Marshmallow), these permissions need to be requested from the user at runtime. This means you will have to have code in your app to request the permissions. A brief example of this is given below. Further instructions for handling this can be found on the Google Developer section.

This file is also referenced in the following sections: Create Activity Styles and Configure Your Application.

To add permissions to the App Manifest

  1. From Android Studio, open your project.
  2. Navigate to the app folder, then from src > main folder, locate your AndroidManifest.xml file. App Manifest
  3. Just above the Application tag, add these lines of code:
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  4. To request permissions for location, include these lines during the startup of your application:

    // If we don't have permissions, request them.
    if (PackageManager.PERMISSION_GRANTED != ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) &&
        PackageManager.PERMISSION_GRANTED != ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION)) {

    This is only a basic implementation of requesting permissions. Please see Google Developer section for handling permissions in greater depth.

results matching ""

    No results matching ""