Adding location permissions

The last thing to do before we can try out our near-complete Where it's Snap app is to add the permissions that let us use the device to get the GPS coordinates.

Tip

These permissions will work fine with Android 6 (Marshmallow) because of the way we configured our project back in Chapter 21, Navigation Drawer and Where It's Snap. If you want a reminder about the new Android permissions in Marshmallow, refer to Chapter 11, Widget Mania, which was the first time we used permissions in this book.

Add the highlighted permissions into the AndroidManifest.xml file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.gamecodeschool.whereitsapp" >

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

  <application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
      android:name=".MainActivity"
      android:label="@string/app_name" >
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>
  </application>

</manifest>

We can now run our app.

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

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