问题
Right.
So I have an app widget.
It has 4 buttons, one one of the buttons I want it to show me the current location of the user on the map.
So - I make a new activity as below:
package com.android.driverwidget;
import java.util.List;
import android.os.Bundle;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.MyLocationOverlay;
import com.google.android.maps.Overlay;
public class MyLocation extends MapActivity{
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
MapView myMapView = (MapView)findViewById(R.id.mapview);
MapController mapController = myMapView.getController();
List<Overlay> overlays = myMapView.getOverlays();
MyLocationOverlay myLocationOverlay = new MyLocationOverlay(this, myMapView);
overlays.add(myLocationOverlay);
myLocationOverlay.enableMyLocation();
}
protected boolean isRouteDisplayed() {
return false;
}
}
And then I added the appropriate uses library line to the manifest
<activity android:name=".MyLocation"
android:label="myLocation">
</activity>
<uses-library android:name="com.google.android.maps" />
Ok yet - when I run the app the following errors occur, looks like it cannot find the MapActivity class, im running it on the GoogleApps 1.5 instead of normal android 1.5 as well.
http://pastebin.com/m3ee8dba2
Somebody plz help me - i am now dying.
回答1:
Fix your manifest by adding/moving
<uses-library android:name="com.google.android.maps" />
into application.
回答2:
When you creating this project you have to choose Google APIs project not only AVD.
回答3:
You're problem might be related to this bug:
http://groups.google.com/group/android-developers/msg/904fae350cda3ebc
来源:https://stackoverflow.com/questions/1153920/android-appwidget-maps-activity-problem