Search code examples
androidgoogle-mapsmapactivity

Android launching a MapActivity?


I'm trying to set up the google maps API for an application. I'm following this link: http://developer.android.com/guide/tutorials/views/hello-mapview.html

Yes, I got my own APK key in the xml and added all the manifest stuff they wanted. But my Java code is giving me an error:

import android.app.Activity;

import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.widget.Toast; import com.google.android.maps.MapActivity;

public class PathTracker extends MapActivity {

@Override
protected boolean isRouteDisplayed() {
    return false;
}

}

Apparently MapActivity is an undefined class, and my last import doesn't help.

Can anyone help me access the MapActivity class?

Thanks.


Solution

  • You need to use the Google APIs SDK instead of the plain Android SDK. You can download this SDK (the one that matches the API level you want) from the android application in the sdk tools. Then edit your project in Eclipse and use that as the SDK.

    1. Go to the android tool (from Eclipse, go to Window -> Android SDK and AVD Manager) or look for the executable in the android sdk directory.
    2. Select Available packages, expand Third party add-ons, expand Google Inc, select the one you want, and download it.
    3. Back in Eclipse, right click your project, select properties. Under the Android menu, select the SDK you downloaded in step 2 as the target.