LocationListener无法正常工作,LogCat中没有任何错误

时间:2014-01-18 01:44:09

标签: android google-maps-android-api-2 locationlistener

我有点绝望,因为不知何故,我的代码才停止工作。

代码:

    public class MainBoard extends FragmentActivity implements OnClickListener, OnTouchListener, LocationListener {
@Override
    protected void onCreate(Bundle savedInstanceState) {
    //Location Listener
        current_location = new MarkerOptions();
        current_location.icon(BitmapDescriptorFactory.fromResource(R.drawable.location));
        LocationManager locationManager = (LocationManager)getSystemService(getApplicationContext().LOCATION_SERVICE);
        locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1, 1, this);
        locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1, 1, this);
    }

//LocationListener
@Override
public void onLocationChanged(Location location) {
    Log.d("LocationListener", "LocationChanged");
     updateCurrentLocation(location);
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {}
@Override
public void onProviderEnabled(String provider) {
    Log.d("LocationListener", "onProviderEnabled");
    instantiatePosition();
}
@Override
public void onProviderDisabled(String provider) {
    Log.d("LocationListener", "onProviderDisabled");
    showGPSOfflineAlert();
}
}

我真的看不到这里的错误,LogCat没有报告任何错误,但没有调用任何方法,甚至没有onProviderEnabled或onProviderDisabled ...

提前致谢:)

0 个答案:

没有答案