Android + GoogleMapsView - 视图无法渲染

时间:2012-01-19 23:21:13

标签: java android google-api

我使用谷歌API 1.6的谷歌地图视图有问题 - 当我在eclipse中使用“调试”按钮启动我的应用程序时 - 地图被正确查看(但并非总是如此)但是当我尝试使用“运行”启动我的应用程序时按钮 - 根本不查看地图。我不是在谈论一个带有网格的灰色屏幕 - 它只是一个黑屏,上面没有任何东西。它有时会在我使用debg配置时发生,但不是经常这样。我无法一直在调试 - 性能太低。当然我有我的Maps API密钥和互联网许可 - 我做了我的功课。

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    minDist = Double.MAX_VALUE;
    MapController mc;
    GeoPoint p;

    setContentView(R.layout.map);

    mapView = (MapView) findViewById(R.id.mapview1);
    mapView.setBuiltInZoomControls(true);

    // set coordinators of Poznan old town
    mc = mapView.getController();

    double lat = Double.parseDouble(PoznanOldTownCoordinates[0]);
    double lng = Double.parseDouble(PoznanOldTownCoordinates[1]);

    p = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6));

    mc.animateTo(p);

    // TODO: parameterize zoom
    mc.setZoom(17);

    getResources().getDrawable(R.drawable.ghost_small);

    GetPointsTask getPointsTask = new GetPointsTask(this);
    getPointsTask.execute();

    // create an overlay that shows our current location
    myLocationOverlay = new LocationOverlay(this, mapView);
    // add this overlay to the MapView and refresh it
    mapView.getOverlays().add(myLocationOverlay);
    mapView.postInvalidate();

}

另外,我在我的日志上得到了这个。

01-19 23:24:08.307: W/ActivityManager(53): Activity idle timeout for HistoryRecord{438226b0 beavers.miu/.activities.Map}

修改

我知道我做错了什么。

GetPointsTask getPointsTask = new GetPointsTask(this);
getPointsTask.execute();

这是一个AsyncTask,你不要将AsyncTasks放在onCreate()方法下。这就是错误

的地方
01-19 23:24:08.307: W/ActivityManager(53): Activity idle timeout for HistoryRecord{438226b0 beavers.miu/.activities.Map}

来自。我做了一些重构,现在它完美无缺。

0 个答案:

没有答案