Commit 5ef74370 authored by afas15's avatar afas15
Browse files

Altitude adicionada

parent eb54a43c
...@@ -39,6 +39,7 @@ public class MainActivity extends ActionBarActivity implements LocationListener ...@@ -39,6 +39,7 @@ public class MainActivity extends ActionBarActivity implements LocationListener
private LocationManager locationManager; private LocationManager locationManager;
private TextView latitudeText; private TextView latitudeText;
private TextView longitudeText; private TextView longitudeText;
private TextView altitudeText;
private String provider; private String provider;
@Override @Override
...@@ -49,6 +50,7 @@ public class MainActivity extends ActionBarActivity implements LocationListener ...@@ -49,6 +50,7 @@ public class MainActivity extends ActionBarActivity implements LocationListener
//Pegamos a referência as TextViews que vamos modificar //Pegamos a referência as TextViews que vamos modificar
latitudeText = (TextView) findViewById(R.id.latitude_label); latitudeText = (TextView) findViewById(R.id.latitude_label);
longitudeText = (TextView) findViewById(R.id.longitude_label); longitudeText = (TextView) findViewById(R.id.longitude_label);
altitudeText = (TextView) findViewById(R.id.altitude_label);
//Construímos o locationManager e pegamos o serviço em execução //Construímos o locationManager e pegamos o serviço em execução
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
...@@ -69,6 +71,7 @@ public class MainActivity extends ActionBarActivity implements LocationListener ...@@ -69,6 +71,7 @@ public class MainActivity extends ActionBarActivity implements LocationListener
}else{ }else{
latitudeText.setText(R.string.no_location_detected); latitudeText.setText(R.string.no_location_detected);
longitudeText.setText(R.string.no_location_detected); longitudeText.setText(R.string.no_location_detected);
altitudeText.setText(R.string.no_location_detected);
} }
} }
...@@ -112,8 +115,10 @@ public class MainActivity extends ActionBarActivity implements LocationListener ...@@ -112,8 +115,10 @@ public class MainActivity extends ActionBarActivity implements LocationListener
public void onLocationChanged(Location location) { public void onLocationChanged(Location location) {
float lat = (float) (location.getLatitude()); float lat = (float) (location.getLatitude());
float lng = (float) (location.getLongitude()); float lng = (float) (location.getLongitude());
latitudeText.setText("Latitude:" + String.valueOf(lat)); float alt = (float) (location.getAltitude());
longitudeText.setText("Longitude" + String.valueOf(lng)); latitudeText.setText("Latitude: " + String.valueOf(lat));
longitudeText.setText("Longitude: " + String.valueOf(lng));
altitudeText.setText("Altitude: " + String.valueOf(alt));
} }
@Override @Override
......
...@@ -21,4 +21,13 @@ ...@@ -21,4 +21,13 @@
android:id="@+id/longitude_label" android:id="@+id/longitude_label"
android:layout_below="@+id/latitude_label" android:layout_below="@+id/latitude_label"
android:layout_centerHorizontal="true" /> android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Altitude:"
android:id="@+id/altitude_label"
android:layout_below="@+id/longitude_label"
android:layout_alignLeft="@+id/latitude_label"
android:layout_alignStart="@+id/latitude_label" />
</RelativeLayout> </RelativeLayout>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment