package org.winplus.serial;
import java.io.IOException;
import android.os.Bundle;
import android.view.KeyEvent;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;
public class SerialDemoActivity extends SerialPortActivity{
EditText mReception;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// setTitle("Loopback test");
mReception = (EditText) findViewById(R.id.EditTextReception);
EditText Emission = (EditText) findViewById(R.id.EditTextEmission);
Emission.setOnEditorActionListener(new OnEditorActionListener() {
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
int i;
CharSequence t = v.getText();
char[] text = new char[t.length()];
for (i=0; i
text[i] = t.charAt(i);
}
try {
mOutputStream.write(new String(text).getBytes());
mOutputStream.write('\n');
} catch (IOException e) {
e.printStackTrace();
}
return false;
}
});
}
@Override
protected void onDataReceived(final byte[] buffer, final int size) {
runOnUiThread(new Runnable() {
public void run() {
if (mReception != null) {
mReception.append(new String(buffer, 0, size));
}
}
});
}
}
资源下载此资源下载价格为3D币,请先登录
资源文件列表
SerialDemo/.classpath , 364
SerialDemo/.project , 846
SerialDemo/Android.mk , 0
SerialDemo/AndroidManifest.xml , 742
SerialDemo/bin/classes/org/winplus/serial/Application.class , 1768
SerialDemo/bin/classes/org/winplus/serial/R$array.class , 440
SerialDemo/bin/classes/org/winplus/serial/R$attr.class , 340
SerialDemo/bin/classes/org/winplus/serial/R$drawable.class , 407
SerialDemo/bin/classes/org/winplus/serial/R$id.class , 435
SerialDemo/bin/classes/org/winplus/serial/R$layout.class , 394
SerialDemo/bin/classes/org/winplus/serial/R$string.class , 516
SerialDemo/bin/classes/org/winplus/serial/R.class , 579
SerialDemo/bin/classes/org/winplus/serial/SerialDemoActivity$1.class , 1611
SerialDemo/bin/classes/org/winplus/serial/SerialDemoActivity$2.class , 988
SerialDemo/bin/classes/org/winplus/serial/SerialDemoActivity.class , 1414
SerialDemo/bin/classes/org/winplus/serial/SerialPortActivity$1.class , 905
SerialDemo/bin/classes/org/winplus/serial/SerialPortActivity$ReadThread.class , 1313
SerialDemo/bin/classes/org/winplus/serial/SerialPortActivity.class , 3093
SerialDemo/bin/classes/org/winplus/serial/utils/SerialPort.class , 2481
SerialDemo/bin/classes/org/winplus/serial/utils/SerialPortFinder$Driver.class , 1853
SerialDemo/bin/classes/org/winplus/serial/utils/SerialPortFinder.class , 3657
SerialDemo/bin/classes/SerialPort.h , 784
SerialDemo/bin/classes.dex , 13076
SerialDemo/bin/res/drawable-hdpi/ic_launcher.png , 3966
SerialDemo/bin/res/drawable-ldpi/ic_launcher.png , 1537
SerialDemo/bin/res/drawable-mdpi/ic_launcher.png , 2200
SerialDemo/bin/resources.ap_ , 12335
SerialDemo/bin/SerialDemo.apk , 20553
SerialDemo/gen/org/winplus/serial/R.java , 1115
SerialDemo/jni/Android.mk , 211
SerialDemo/jni/Application.mk , 36
SerialDemo/jni/SerialPort.c , 5251
SerialDemo/jni/SerialPort.h , 784
SerialDemo/libs/armeabi/libserial_port.so , 29700
SerialDemo/proguard.cfg , 1248
SerialDemo/project.properties , 361
SerialDemo/res/drawable-hdpi/ic_launcher.png , 4147
SerialDemo/res/drawable-ldpi/ic_launcher.png , 1723
SerialDemo/res/drawable-mdpi/ic_launcher.png , 2574
SerialDemo/res/layout/main.xml , 840
SerialDemo/res/values/baudrates.xml , 1874
SerialDemo/res/values/strings.xml , 444
SerialDemo/src/org/winplus/serial/Application.java , 1504
SerialDemo/src/org/winplus/serial/SerialDemoActivity.java , 1945
SerialDemo/src/org/winplus/serial/SerialPortActivity.java , 2532
SerialDemo/src/org/winplus/serial/utils/SerialPort.java , 1896
SerialDemo/src/org/winplus/serial/utils/SerialPortFinder.java , 2999