I'm doing an app where I try to create an event, save the date and time in a certain format and then retrieve them. Android Studio tells me
"can not find symbol"
as it does not find the variables. I define the variables later, but because of the structure of the program, I need you to read them not only later on, but also before, within public void
. Are the variables show and show hours that you can not read in the first public void.
there goes the code:
@Override
public void onMapReady(GoogleMap googleMap) {
map = googleMap;
map.setPadding(10, 10, 10, 10);
map.moveCamera(CameraUpdateFactory.zoomTo(16.0f));
map.setMyLocationEnabled(true);
if( hasLocation(this) ) {
float latitude = getLastLatitude(this);
float longitude = getLastLongitude(this);
float accuracy = getLastAccuracy(this);
String street = getLastStreet(this);
locationTextView.setText("Aparcaste en: ("+latitude+","+longitude+")");
locationTextView.setVisibility(View.VISIBLE);
for (BluetoothDevice device : btAdapter.getBondedDevices()) {
if (device.getAddress().equals(carBtAddress)) {
{
}
}
}
if( street==null || street.length()==0 ) {
if(Geocoder.isPresent()) {
Location last = new Location("be.ndusart");
last.setLatitude(latitude);
last.setLongitude(longitude);
(new GetAddressTask()).execute(last);
}
} else
locationTextView.setText("Aparcaste en: " + street +" "+fechamostrar+ " " +horamostrar);
.
.
.
.
@Override
protected void onPostExecute(String result){
Date d=new Date();
SimpleDateFormat fecc=new SimpleDateFormat("dd-MM-yyyy");
String fechacComplString = fecc.format(d);
SimpleDateFormat ho=new SimpleDateFormat("hh:mm:ss");
String horaString = ho.format(d);
SharedPreferences preferences = getSharedPreferences("MisPreferencias", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putString("hora", horaString);
editor.putString("fecha", fechacComplString);
editor.commit();
String fechamostrar = preferences.getString("fecha","01-01-2017");
String horamostrar = preferences.getString("hora","01-01-2017");
if( result != null && result.length() > 0 ) {
locationTextView.setText("Aparcaste en: "+result+ " "+fechamostrar+ " " +horamostrar);
}