【发布时间】:2012-05-18 17:17:01
【问题描述】:
我正在测试使用内置 Eclipse 工具将坐标发送到 Android 模拟器的选项。但它似乎没有收到它们。我有这个简单的代码:
public class Main extends MapActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MapView view = (MapView) findViewById(R.id.themap);
view.setBuiltInZoomControls(true);
final MapController mp = view.getController();
LocationManager manager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
LocationListener listener = new LocationListener() {
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub
}
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}
public void onLocationChanged(final Location location) {
// TODO Auto-generated method stub
mp.setCenter(new GeoPoint((int)location.getLatitude(), (int)location.getLongitude()));
}
};
manager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, listener);
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
我在 Manifest 中拥有 ACCESS_FINE_LOCATION 和 INTERNET 的权限。 如果有人有任何解释,我将不胜感激。
【问题讨论】:
-
我不想给出这个笼统的答案,但是,如果它不起作用,那么你在模拟器方面做错了。它可能不在您的代码中。
-
还有哪些可能的错误?
-
不幸的是,我能给你的最好建议是准确研究应该如何完成,并找出你偏离它的地方。此外,谷歌和 SO 搜索将提供大量信息。
标签: android google-maps android-emulator