Android MapView Permissions and Prerequisites
Apparently you need the:
<uses-permission android:name=”android.permission.ACCESS_COARSE_LOCATION”></uses-permission>
<uses-permission android:name=”android.permission.ACCESS_FINE_LOCATION”></uses-permission>
<uses-permission android:name=”android.permission.INTERNET”></uses-permission>
in your manifest file. Wasted a day on that INTERNET one! I swear it was working yesterday without it, but today I was just getting a blank map grid.
Other gotchas about MapViews:
- In the manifest file, those <uses-permissions> elements should come before your <application> element
- In order to define a MapView in an XML layout file, you can’t use a <MapView> element. Instead, you must have a <com.google.android.maps.MapView/> element, and you need to have a android:apiKey attribute in there as well, with a valid android maps api key. Not intuitive.
- Activity.findViewById is a very useful function
- The only type of Activity that can show maps is a MapActivity
7 Comments