Mapview example crashing on launch
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.catego开发者_高级运维ry.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
you have to change extends Activity
to extends MapActivity
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.
精彩评论