I have two strings (latitude and longitude) stored within my database. I only want an activity to start once the device my app is installed on reaches a certain location.
I thought about writing an if-statement (see code below) in order to solve this however it is not working.
Is there another way of doing this?
Could anyone provide me with suggestions?
tvLatitude.setText(String.valueOf(gps.getLatitude()));
tvLongitude.setText(String.valueOf(gps.getLongitude()));
String longi = tvLongitude.getText().toString();
String lati = tvLatitude.getText().toString();
String WorkLocationlongi = "REQUIRED LONGITUDE";
String WorkLocationlati = "REQUIRED LATITUDE";
mRootRef.child("Longitude").setValue(longi);
mRootRef.child("Latitude").setValue(lati);
if (longi.equals(WorkLocationlati)&& lati.equals(WorkLocationlongi)){
String dtbClockon = tvClock.getText().toString();
mRootRef.child("Dave_Clock_on_date").setValue(formattedDateOnly);
mRootRef .child("Dave_Clock_on").setValue(dtbClockon);
startActivity(new Intent(getBaseContext(), MainActivity.class));
}
else {
Toast.makeText(context,"Not in work area please enter the yard and try again",Toast.LENGTH_SHORT).show();
}
Thanks.