プロジェクトの MapActivity を使用しています。
メインクラスにこの onCreate メソッドがあります:
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 メソッド:
@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();
}
}
}
私が抱えている問題は、実行中に次の 2 つのエラー メッセージが表示されることです (このアクティビティは正常に動作します..):
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.
しかし、「新しい」APIでそれを取得できるかどうかはわかりません。カーソルマネージャーで行っていることは次のとおりです。
lm = (LocationManager) this.getSystemService(LOCATION_SERVICE);
onResume().. Somoene はそれを修正するアイデアを持っていますか?