Java 比较Android中的mac地址?

Java 比较Android中的mac地址?,java,android,android-wifi,mac-address,Java,Android,Android Wifi,Mac Address,我能够得到路由器的mac地址;但是当我比较它时,它没有显示任何东西。谁能告诉我哪里错了 @Override public void onClick(View v) { // TODO Auto-generated method stub getMacId(); // myTimer.scheduleAtFixedRate(myTimerTask, 0, 5000); display.setText(" Mac Address of current connect

我能够得到路由器的mac地址;但是当我比较它时,它没有显示任何东西。谁能告诉我哪里错了

@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");
    }
字符串是一个对象

要比较其值而不是内存地址,请使用

等于(字符串)

getMacId()=“usmanWing”
更改为
getMacId().equals(“usmanWing”)

由于您正在比较两个字符串,因此应使用
“YOUR_STRING”.equals(“COMPARE_STRING”)
方法。

可能重复的