0

I was able to get the mac address of the router; But when I compare it it shows nothing. Can anyone tell me where I'm wrong?

@Override
public void onClick(View v) {
    // TODO Auto-generated method stub

    getMacId();
    // myTimer.scheduleAtFixedRate(myTimerTask, 0, 5000);
    display.setText(" Mac Address of current connected wifi is");
    // MacText.setText(getMacId());
    String MacID = getMacId(); 
    box.setText(MacID);

    String rajaWing = "f4:7f:35:5f:43:50" ;
    String usmanWing = "f4:7f:35:5f:43:a0"; 
    String shahzadWing = "00:3a:98:88:91:a0";
    //sets location name
    if (getMacId() == "usmanWing") {
        MacText.setText("Usman's Wing");
    }
Unihedron
  • 10,902
  • 13
  • 62
  • 72
Usman
  • 73
  • 7
  • possible duplicate of [How do I compare strings in Java?](http://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java) – Gumbo Sep 21 '14 at 15:21

2 Answers2

1

Change getMacId() == "usmanWing" to getMacId().equals("usmanWing")

Since you are comparing two Strings so you should use "YOUR_STRING".equals("COMPARE_STRING") method.

ashokramcse
  • 2,841
  • 2
  • 19
  • 41
0

String is an Object.

In order to compare its value, not its memory address, use

String.equals(String);

How do I compare strings in Java?

Community
  • 1
  • 1
El Abogato
  • 123
  • 1
  • 5