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
3 responses so far ↓
1 Frank Trollmann // Nov 4, 2008 at 4:07 am
And don’t foreget: if you want to use a MapActivity in your code the following tag is needed in your Manifest.xml:
it belongs INSIDE the tag (right before closing it worked fine for me)
regards Frank
2 Frank Trollmann // Nov 4, 2008 at 4:12 am
(INSIDE the application tag that is )
3 Matthew // Nov 8, 2008 at 1:29 pm
Thank you for this article! I was beating my head against the wall thinking my maps API key wasn’t working when the problem was that my permissions were inside my application element.
Leave a Comment