Exemplo n.º 1
0
 @Override
 protected void onResume() {
   super.onResume();
   // mise à jour du GPS
   locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 0, this);
   locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000, 0, this);
 }
  @Override
  protected void onResume() {
    super.onResume();

    status.setText(getString(R.string.waiting_for_location));
    status.setVisibility(View.VISIBLE);

    currentLocation = null;
    mapView.getController().setZoom(12);

    if (selectedStop == null) {
      status.setText(getString(R.string.waiting_for_location));
      status.setVisibility(View.VISIBLE);
      try {
        LocationService.registerForLocationUpdates(getApplicationContext(), this);

      } catch (NoProvidersException e) {
        status.setText(getString(R.string.no_location_providers));
        status.setVisibility(View.VISIBLE);
      }
    }

    FetchRouteStopsTask fetchRouteStopsTask =
        new FetchRouteStopsTask(
            new StopsService(
                ApiFactory.getApi(getApplicationContext()),
                new StopsCache(getApplicationContext()),
                getApplicationContext()));
    fetchRouteStopsTask.execute(selectedRoute);
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (this.getIntent().getExtras() != null && this.getIntent().getExtras().get("route") != null) {
      selectedRoute = (Route) this.getIntent().getExtras().get("route");
    }

    if (this.getIntent().getExtras() != null && this.getIntent().getExtras().get("stop") != null) {
      selectedStop = (Stop) this.getIntent().getExtras().get("stop");
    }

    status = (TextView) findViewById(R.id.status);
  }
Exemplo n.º 4
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // chargement du fichier map
    File map =
        new File(
            Environment.getExternalStorageDirectory().toString() + "/Arboretum/Map/grenoble.map");
    // ajout de la map proprement
    mapView = new MapView(this);
    mapView.setMapFile(map);
    // on rend la map cliquable
    mapView.setClickable(true);
    // on rend la map zoomable
    mapView.setBuiltInZoomControls(true);
    // affichage de la map
    setContentView(mapView);
    // Creation d'un marker, un objet Drawable
    Drawable defaultMarker = getResources().getDrawable(R.drawable.letter_a);
    Drawable location = getResources().getDrawable(R.drawable.location_unoriented);
    // ici on les stock. La deuxieme liste n'est pas MyItemizdOverlay pour
    // la simple raison qu'elle va stocker notre curseur de position
    // dont on ne souhaite pas qu'il y ai de reaction si on tap dessus
    ArrayItemizedOverlay itemizedOverlay = new MyItemizedOverlay(defaultMarker, this);
    ArrayItemizedOverlay itemizedOverlay2 = new ArrayItemizedOverlay(location);
    // create a GeoPoint with the latitude and longitude coordinates
    GeoPoint myPos = new GeoPoint(0, 0);

    // create an OverlayItem with title and description
    item = new OverlayItem(Global.getArbo(), "Arboretum", "Localisation de l'arboretum.");
    item2 = new OverlayItem(myPos, "Moi", "Ma position.");
    item.setMarker(ItemizedOverlay.boundCenter(defaultMarker));
    item2.setMarker(ItemizedOverlay.boundCenter(location));
    // add the OverlayItem to the ArrayItemizedOverlay
    itemizedOverlay.addItem(item);
    itemizedOverlay2.addItem(item2);
    // Le GPS
    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1, 0, this);
    sm = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
    if (sm.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD) != null) {
      // success! there's a magnetometer
    } else {
      Toast.makeText(this, "Problème d'accelerometer", Toast.LENGTH_LONG).show();
    }
    // add the ArrayItemizedOverlay to the MapView
    mapView.getOverlays().add(itemizedOverlay);
    mapView.getOverlays().add(itemizedOverlay2);
    // je me centre sur moi
    mapView.setCenter(item2.getPoint());
    // puis je zoom *2
    mapView.zoom((byte) 2, 2);
    // Récupère le root layout
    FrameLayout fl =
        (FrameLayout)
            this.getWindow().getDecorView().getRootView().findViewById(android.R.id.content);
    // Crée le bouton
    myButton = new Button(this);
    myButton.setText("Recentrer");
    myButton.setLayoutParams(
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    // Ajoute le bouton au layout
    fl.addView(myButton);
    myButton.setOnClickListener(this);
  }
Exemplo n.º 5
0
 @Override
 protected void onPause() {
   super.onPause();
   // pause du GPS
   locationManager.removeUpdates(this);
 }
 @Override
 protected void onPause() {
   super.onPause();
   LocationService.turnOffLocationUpdates(this.getApplicationContext(), this);
 }
 @Override
 protected void onPause() {
   super.onPause();
 }
 @Override
 protected void onResume() {
   super.onResume();
 }
 @Override
 protected void onStart() {
   super.onStart();
 }
Exemplo n.º 10
0
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
 }