0

I'm using a MapActivity from my project.

I have this onCreate method on main class :

    public class TabMap extends MapActivity implements LocationListener
{
    private MapView mapView;
    private MapController mc;

    private LocationManager lm;

    private double latitude;
    private double longitude;
    private double altitude;
    private float accuracy;

    private MyLocationOverlay myLocation = null;
    private Button select;

    ListInterestPoints currentListofInterest = null;
    String provider;

    @Override
    protected void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.onglet_map);

        // instance de l'objet mapView
        mapView = (MapView) this.findViewById(R.id.mapView);

        // ajout des boutons zoom et dezoom
        mapView.setBuiltInZoomControls(true);

        mc = mapView.getController();
        // niveau de zoom a l'initialisation de la map (1->21)
        mc.setZoom(18);

        // instanciation de la classe MyLocationOverlay
        myLocation = new MyLocationOverlay(getApplicationContext(), mapView);

        // ajout de la location a la MAP
        mapView.getOverlays().add(myLocation);

        // afficher le point
        myLocation.enableMyLocation();
        // afficher la boussole
        myLocation.enableCompass();

        // bouton qui repositionne sur la position de l'utilisateur
        select = (Button) findViewById(R.id.googlemaps_select_location);
        select.setOnClickListener(new OnClickListener() 
            {
                public void onClick(View v) 
                {
                    GeoPoint point = new GeoPoint((int) (latitude * 1E6), (int) (longitude * 1E6));
                    mc.animateTo(point);
                    mc.setCenter(point);
            }});

        // centrage sur la postion de l'utilisateur au 1er lancement
        myLocation.runOnFirstFix(new Runnable() 
        {
            public void run() 
            {
                mc.animateTo(myLocation.getMyLocation());
                mc.setZoom(18);
            }
        });
    }

OnResume method:

@Override
    protected void onResume()
    {
        super.onResume();

        lm = (LocationManager) this.getSystemService(LOCATION_SERVICE);
        if (lm.isProviderEnabled(LocationManager.GPS_PROVIDER))
            lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 10000, 0, this);
        lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 10000, 0, this);

        /** Gestion du remplissage des item Shop sur la MAP **/
        if (checkPromotionNotNull() == true)
        {
            // 1er lancement ac list null
            if (currentListofInterest == null)
            {
                putInterestPointsOnMap();
            }
            else
            {
                currentListofInterest.removeAllOverlayItem();
                putInterestPointsOnMap();
            }
        }
        else
        {
            if (currentListofInterest == null){}
            else
                currentListofInterest.removeAllOverlayItem();
        }
    }
    }

The problem i have is : i've got these 2 error messages when i'm running it (this activity works fine..):

08-16 14:32:28.390: E/SensorManager(5605): registerListener :: handle = 2  name= Mag & Acc Combo Orientation Sensor delay= 60000 Listener= android.hardware.SensorManager$LegacyListener@405dbf70
08-16 14:32:28.398: E/SensorManager(5605): =======>>>Sensor Thread RUNNING <<<========
08-16 14:32:28.406: E/SensorManager(5605): reg :: handle = 2

08-13 12:37:43.855: I/SensorManager(25211): This application is using deprecated SensorManager API which will be removed someday.  Please consider switching to the new API.

But I have no idea tu get it in "new" API.. The only one thing I'm doing with cursor Manager is :

lm = (LocationManager) this.getSystemService(LOCATION_SERVICE);

into onResume().. Somoene does have an idea to fix it ?

eento
  • 761
  • 4
  • 20
  • 53

2 Answers2

3

It's because of you calling myLocation.enableCompass()

Here's the source of enableCompass implementation in Android from Android source code:

 @Override
    public boolean enableCompass() {
        mCompassEnabled = true;
        mSensorOrientation = mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION);
        mSensorManager.registerListener(this, mSensorOrientation, SensorManager.SENSOR_DELAY_NORMAL);
        return true;
    }

This one uses Sensor.TYPE_ORIENTATION and that TYPE_ORIENTATION constant is now deprectated.

So, it's not your fault, those modules they are speaking between themselves, and you can ignore that.

Alexander Kulyakhtin
  • 47,782
  • 38
  • 107
  • 158
  • Oh ok.. so if I want to remove this SensorManager Error I just have to remove this compass ?! If yes do you know an other graphic compass ? – eento Aug 17 '12 at 09:13
  • 1
    @eento No, you shouldn't do anything about that error. It's LocationManager who uses the deprecated API and SensorManager tells about that to LocationManager. They will figure that out with Google eventually. Clients shall not do anything about it. – Alexander Kulyakhtin Aug 17 '12 at 09:21
0

where is your Location Listener class:

private final LocationListener locationListener = new LocationListener() 
{ 

    @Override 
    public void onLocationChanged(Location location) { 
        updateWithNewLocation(location); 
    } 

    @Override 
    public void onProviderDisabled(String provider) { 
        updateWithNewLocation(null); 
    } 

    @Override 
    public void onProviderEnabled(String provider) { 
    } 

    @Override 
        public void onStatusChanged(String provider, int status, Bundle extras) { 
    } 

};

And also you missed this part:

@Override
protected boolean isRouteDisplayed() {
    // TODO Auto-generated method stub
    return false;
}
sloth
  • 99,095
  • 21
  • 171
  • 219
Ram
  • 1,687
  • 3
  • 18
  • 28