在 HAL层写了一个接受数据的线程,接送到数据后,马上通过jni的回调函数,将数据给应用层。整个过程,数据都能传给了 UI 上的EditText(通过runOnUiThread的方式),并且也能显示。 但是发现了一个问题,当我的设备因为重力感应进行了自动翻转过后,数据就无法显示在界面上editText 上了,但数据都能传到UI,而且是有值的,并且跟踪代码,editText.getText的到的数据也是正确的,但就是UI上的EditText的文本显示没有变化。
如果这个时候,我用按钮按下对EditText进行赋值,是可以显示的。 应用代码见下面。
我知道窗体翻转,会重新创建的窗体的。就是第一次开启,都很正常。只要翻转过后,数据就无法显示。 public void onReceiverListener(String ReadData, int length) {
// TODO Auto-generated method stub

onDataReceived(ReadData, length);

 

}

protected void onDataReceived(final String ReadData, final int size) {
this.runOnUiThread(new Runnable() {
public void run() {


try{
if (EdData != null) {
 
 
EdData.append(ReadData+"\r\n");
 
Log.d("test",ReadData);
 
}
}catch (Exception e ) {
e.printStackTrace();
System.out.print("IOException\n");


}
});

}