jeudi 27 octobre 2016

how do i check 2 strings in an if statement

i have 2 strings stored in my data base which are longitude and latitude location of the device my app is installed on. i only want an activity to start once it reaches a certain location. i thought writing an if statement something like below but it wouldnt work. is there another way of doing it or am i typing something wrong

                    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();
                    }

Aucun commentaire:

Enregistrer un commentaire