0

i am trying mapview example. But it is crashing on activity launch. my build target is Google API for version 2.1. it is crashing on both device and emulator. Also, i am not able to Override method isRouteDisplayed. here is my code

package com.sandy.hellogooglemaps;

import android.app.Activity;
import android.os.Bundle;

import com.google.android.maps.MapView;

public class HelloGoogleMaps extends Activity {

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);        
        MapView mapView = (MapView) findViewById(R.id.mapview);
        mapView.setBuiltInZoomControls(true);
    }    

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

}

and my manifest file is

<application android:icon="@drawable/icon" 
android:theme="@android:style/Theme.NoTitleBar"
android:label="@string/app_name">
    <activity android:name=".HelloGoogleMaps"
              android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <uses-library android:name="com.google.android.maps" />
</application>
<uses-permission android:name="android.permission.INTERNET" />

my xml for layout is

peter_budo
  • 1,748
  • 4
  • 26
  • 48
sandeep
  • 937
  • 2
  • 12
  • 22

2 Answers2

1

You should extend MapActivity, not Activity.

Also make sure that you have provided to your MapView valid Google Maps Api Key: http://code.google.com/intl/iw-IL/android/add-ons/google-apis/mapkey.html

I hope it helps.

1

you have to change extends Activity to extends MapActivity

Dharmendra
  • 33,296
  • 22
  • 86
  • 129