java - Android - If then doesn't work..? -
this question has answer here:
- how compare strings in java? 23 answers
i hitting huge wall here. got code checks on database result :
chosenslotdao.open(); log.d("id", chosenslotdao.getid()); log.d("isparked", chosenslotdao.getisparked()); log.d("parkedrow", chosenslotdao.getparkedrow()); log.d("selectedslot", chosenslotdao.getselectedslot()); string idstatus = chosenslotdao.getid(); string isparkedstatus = chosenslotdao.getisparked(); string parkedrowstatus = chosenslotdao.getparkedrow(); string selectedslotstatus = chosenslotdao.getselectedslot(); final string outputa = this.getoutput(this, slota); if(idstatus == id && isparkedstatus == isparked && parkedrowstatus != parkeda && selectedslotstatus != slota) { arrivetview.settext(alreadyparked + chosenslotdao.getparkedrow()); } else if(idstatus == id && isparkedstatus == isnotparked && parkedrowstatus != parkeda && selectedslotstatus != slota) { toast.maketext(getapplicationcontext(), wrongparkingrow, toast.length_long).show(); chosenslotdao.updateslot(id, slota, parkeda, isparked); } else if(idstatus == id && isparkedstatus == isparked && parkedrowstatus == parkeda && selectedslotstatus == slota) { chosenslotdao.updateslot(id, slota, setempty, isnotparked); dbupdateadd.execute(slota); intent myintent = new intent(parkaarrive.this, parkleaving.class); parkaarrive.this.startactivity(myintent); } else if(outputa.isempty()) { arrivetview.settext(isfull); } else { toast.maketext(getapplicationcontext(), nowparked, toast.length_long).show(); chosenslotdao.updateslot(id, slota, parkeda, isparked); arrivetview.settext(chosenslotdao.getselectedslot()); dbupdate.execute(slota); }
the class started tapping nfc tag.
logcat returns :
06-15 04:35:10.818: d/id(12294): 1 06-15 04:35:10.818: d/isparked(12294): 1 06-15 04:35:10.819: d/parkedrow(12294): parkeda 06-15 04:35:10.819: d/selectedslot(12294): slota 06-15 04:35:10.829: d/link(12294): http://parkit.byethost9.com/db_show_slot.php?slot_name=slota 06-15 04:35:11.681: d/line(12294): 14
it shows user parked, parkedrow parkeda, , slota slota. if
not work.
but when start activity again, nothing except
else if(outputa.isempty()) { arrivetview.settext(isfull); } else { toast.maketext(getapplicationcontext(), nowparked, toast.length_long).show(); chosenslotdao.updateslot(id, slota, parkeda, isparked); arrivetview.settext(chosenslotdao.getselectedslot()); dbupdate.execute(slota); }
works.
where in code doing wronggg?? tell me if left required info untold..
update : seems need change code can compare string
, , yes it's problem i'm facing.
you should use equals
method compare string
objects instead of the == operator
.
see following question full explanation: how compare strings in java?
Comments
Post a Comment