获取与GPS /网络的Andr​​oid的MapView用户当前位置当前位置、用户、网络、GPS

2023-09-07 12:42:09 作者:你长得跟闹着玩似的

您好,我一直在使用本指南确定locationof用户:的http://developer.android.com/guide/topics/location/obtaining-user-location.html

Hello I've been using this guide to determine the locationof the user: http://developer.android.com/guide/topics/location/obtaining-user-location.html

和我目前的code是这样的:

and my current code looks like this:

    LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);

    LocationListener locationListener = new LocationListener() {
        public void onLocationChanged(Location location) {
            test = new GeoPoint((int)location.getLatitude()*1000000, (int)location.getAltitude()*1000000);
            mapController.animateTo(test);
        }

        @Override
        public void onProviderDisabled(String provider) {
            // TODO Auto-generated method stub

        }
        @Override
        public void onProviderEnabled(String provider) {
            // TODO Auto-generated method stub

        }
        @Override
        public void onStatusChanged(String provider, int status, Bundle extras) {
            // TODO Auto-generated method stub

        }
    };
    locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
}

我只得到错误和应用程序,虽然关闭,当我使用这个活动。

I only get error and the app shuts down though when I'm using this activity.

为感谢帮助

/奔

推荐答案

我解决了这个问题,我没有实例mapContoller:>。不过,我现在已经另一个问题。我将在另外的问题。

I solved it, I didn't instantiate mapContoller :>. But I've another problem now. which I will post in another question.