开发者

target platform android vs. google api

I followed this tutorial: http://developer.android.com/resources/tutorials/views/hello-mapview.html and it runs ok, except when I click on my icon in the map, the dialogue box does not come up. And the application stops. Did anyone else run into a similar problem?

I don't know what is google api; can someone explain it to me please? Does this mean that the code in above tutorial will not run on an android handset?

Here is my code:

package com.example开发者_JAVA技巧.hellogooglemaps;

import java.util.List;

import android.graphics.drawable.Drawable;
import android.os.Bundle;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;

public class Hellogooglemaps extends MapActivity {
    /*Called to say that we are not displaying any route information*/
    @Override
    protected boolean isRouteDisplayed() {
        return false;
    }

    /** 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);
        List<Overlay> mapOverlays = mapView.getOverlays();
        Drawable drawable = this.getResources().getDrawable(R.drawable.icon);
        HelloItemizedOverlay itemizedoverlay = new HelloItemizedOverlay(drawable);
        GeoPoint point = new GeoPoint(19240000,-99120000);
        OverlayItem overlayitem = new OverlayItem(point, "Hola, Mundo!", "I'm in Mexico City!");
        itemizedoverlay.addOverlay(overlayitem);
        mapOverlays.add(itemizedoverlay);
    }
}


Most of Android handsets include the Google Libraries for Google Maps. The Google Maps API is basically a set of classes that allows you to use Google Maps in a easy way from your Android App.

Of course... there are some android handsets that don't have the Google Maps libraries, maybe for licenses issues. Thus, those devices won't be able to run your app.

With regards to your programming problem, it will help if you edit your question and provide a relevant snippet your code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜