Android字节类型比较

时间:2015-10-15 00:32:07

标签: c# android byte

我的代码适用于PC,但在Android上运行时只会出现问题。 (Unity3d c#)

byte[] arr1;
byte[] arr2 = new byte[19];

arr1=readfrombuffer(); // read bytes from bluetooth device 
arr2 = arr1; //put value with for()

print(arr2[1].toString()); // works well (255)

if(arr2[1]==255)
{
         print("yes"); //never print   <- problem
}

if(arr2[1]==255) , if(arr2[1]==(byte)255) , if(arr2[1]==0xFF) ...仍然无效

1 个答案:

答案 0 :(得分:0)

更改 FROM

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.SwingWorker;

public class SwingWorkerListener<W extends SwingWorker> implements PropertyChangeListener {

    @Override
    public void propertyChange(PropertyChangeEvent evt) {
        W worker = (W) evt.getSource();
        switch (evt.getPropertyName()) {
            case "state":
                workerStateChanged(worker);
                switch (worker.getState()) {
                    case STARTED:
                        workerStarted(worker);
                        break;
                    case DONE:
                        workerDone(worker);
                        break;
                }
                break;
            case "progress":
                workerProgressUpdated(worker);
                break;
        }
    }

    protected void workerProgressUpdated(W worker) {
    }

    protected void workerStateChanged(W worker) {
    }

    protected void workerStarted(W worker) {
    }

    protected void workerDone(W worker) {
    }

}

if(arr2[1]==255)
{
         print("yes"); //never print   <- problem
}