expletive inserted

Does cursing make you feel better? Shit yeah, me too.

expletive inserted header image 2

Android MapView Permissions and Prerequisites

October 26th, 2008 · 3 Comments

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:

  1. In the manifest file, those <uses-permissions> elements should come before your <application> element
  2. 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.
  3. Activity.findViewById is a very useful function
  4. The only type of Activity that can show maps is a MapActivity

Tags: uncategorized

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

Leave comment with OpenID

Or, the normal wordpress way: