2010-07-17 46 views
1

我按照这个教程:http://developer.android.com/resources/tutorials/views/hello-mapview.html 它运行正常,除非我点击我的图标在地图上,对话框没有出现。应用程序停止。还有其他人遇到过类似的问题吗?目标平台android vs谷歌api

我不知道google api是什么;有人可以向我解释吗?这是否意味着上述教程中的代码不会在android手机上运行?

这里是我的代码:

package com.example.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); 
    } 
} 

回答

1

大部分Android手机包括谷歌图书馆的谷歌地图。 Google Maps API基本上是一组类,可让您通过Android应用轻松使用Google地图。

当然......有一些android手机没有Google地图库,可能是许可问题。因此,这些设备将无法运行您的应用程序。

关于你的编程问题,如果你编辑你的问题并提供你的代码的相关片段,这将有所帮助。

+0

感谢您的评论。我将代码添加到了我的请求中。希望这可以帮助。你能告诉我我做错了什么吗? – Sean 2010-09-19 21:29:57

+0

你可以在应用程序崩溃后粘贴logcat吗? – Cristian 2010-09-19 23:36:32