资源简介
使用时 广播注册 和meta-data的注册 必须在Acticvity节点下,功能:扫描串口信息 读写串口数据 不需要使用 root权限
代码片段和文件信息
/* Copyright 2011 Google Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not write to the Free Software
* Foundation Inc. 51 Franklin Street Fifth Floor Boston MA 02110-1301
* USA.
*
* Project home page: http://code.google.com/p/usb-serial-for-android/
*/
package com.hoho.android.usbserial.examples;
import android.app.Activity;
import android.content.Context;
import android.hardware.usb.UsbManager;
import android.os.Bundle;
import android.util.Log;
import android.widget.ScrollView;
import android.widget.TextView;
import com.hoho.android.usbserial.driver.UsbSerialDriver;
import com.hoho.android.usbserial.driver.UsbSerialProber;
import com.hoho.android.usbserial.util.HexDump;
import com.hoho.android.usbserial.util.SerialInputOutputManager;
import java.io.IOException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* A sample Activity demonstrating USB-Serial support.
*
* @author mike wakerly (opensource@hoho.com)
*/
public class DemoActivity extends Activity {
private final String TAG = DemoActivity.class.getSimpleName();
/**
* The device currently in use or {@code null}.
*/
private UsbSerialDriver mSerialDevice;
/**
* The system‘s USB service.
*/
private UsbManager mUsbManager;
private TextView mtitleTextView;
private TextView mDumpTextView;
private ScrollView mScrollView;
private final ExecutorService mExecutor = Executors.newSingleThreadExecutor();
private SerialInputOutputManager mSerialIoManager;
private final SerialInputOutputManager.Listener mListener =
new SerialInputOutputManager.Listener() {
@Override
public void onRunError(Exception e) {
Log.d(TAG “Runner stopped.“);
}
@Override
public void onNewData(final byte[] data) {
DemoActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
DemoActivity.this.updateReceivedData(data);
}
});
}
};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mUsbManager = (UsbManager) getSystemService(Context.USB_SERVICE);
mtitleTextView = (TextView) findViewById(R.id.demotitle);
mDumpTextView =
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2012-12-04 17:43 usb-serial-for-android-master\
文件 218 2012-12-04 17:43 usb-serial-for-android-master\.gitignore
文件 69 2012-12-04 17:43 usb-serial-for-android-master\CHANGELOG.txt
文件 7651 2012-12-04 17:43 usb-serial-for-android-master\LICENSE.txt
文件 1695 2012-12-04 17:43 usb-serial-for-android-master\README.md
目录 0 2012-12-04 17:43 usb-serial-for-android-master\UsbSerialExamples\
文件 438 2012-12-04 17:43 usb-serial-for-android-master\UsbSerialExamples\.classpath
文件 820 2012-12-04 17:43 usb-serial-for-android-master\UsbSerialExamples\.project
目录 0 2012-12-04 17:43 usb-serial-for-android-master\UsbSerialExamples\.settings\
文件 23139 2012-12-04 17:43 usb-serial-for-android-master\UsbSerialExamples\.settings\org.eclipse.jdt.core.prefs
文件 117 2012-12-04 17:43 usb-serial-for-android-master\UsbSerialExamples\.settings\org.eclipse.jdt.ui.prefs
文件 1235 2012-12-04 17:43 usb-serial-for-android-master\UsbSerialExamples\AndroidManifest.xm
文件 1248 2012-12-04 17:43 usb-serial-for-android-master\UsbSerialExamples\proguard.cfg
文件 409 2012-12-04 17:43 usb-serial-for-android-master\UsbSerialExamples\project.properties
目录 0 2012-12-04 17:43 usb-serial-for-android-master\UsbSerialExamples\res\
目录 0 2012-12-04 17:43 usb-serial-for-android-master\UsbSerialExamples\res\drawable-hdpi\
文件 4147 2012-12-04 17:43 usb-serial-for-android-master\UsbSerialExamples\res\drawable-hdpi\ic_launcher.png
目录 0 2012-12-04 17:43 usb-serial-for-android-master\UsbSerialExamples\res\drawable-ldpi\
文件 1723 2012-12-04 17:43 usb-serial-for-android-master\UsbSerialExamples\res\drawable-ldpi\ic_launcher.png
目录 0 2012-12-04 17:43 usb-serial-for-android-master\UsbSerialExamples\res\drawable-mdpi\
文件 2574 2012-12-04 17:43 usb-serial-for-android-master\UsbSerialExamples\res\drawable-mdpi\ic_launcher.png
目录 0 2012-12-04 17:43 usb-serial-for-android-master\UsbSerialExamples\res\layout\
文件 798 2012-12-04 17:43 usb-serial-for-android-master\UsbSerialExamples\res\layout\main.xm
目录 0 2012-12-04 17:43 usb-serial-for-android-master\UsbSerialExamples\res\values\
文件 182 2012-12-04 17:43 usb-serial-for-android-master\UsbSerialExamples\res\values\strings.xm
目录 0 2012-12-04 17:43 usb-serial-for-android-master\UsbSerialExamples\res\xm
文件 430 2012-12-04 17:43 usb-serial-for-android-master\UsbSerialExamples\res\xm
目录 0 2012-12-04 17:43 usb-serial-for-android-master\UsbSerialExamples\src\
目录 0 2012-12-04 17:43 usb-serial-for-android-master\UsbSerialExamples\src\com\
目录 0 2012-12-04 17:43 usb-serial-for-android-master\UsbSerialExamples\src\com\hoho\
目录 0 2012-12-04 17:43 usb-serial-for-android-master\UsbSerialExamples\src\com\hoho\android\
............此处省略29个文件信息
- 上一篇:PickAddressAndDate
- 下一篇:Android 蓝牙使用
相关资源
- Android 蓝牙使用
- PickAddressAndDate
- android-support-v7-appcompat.jar
- Android项目---闹铃备忘录
- android 英文生词本设计
- 菜鸟窝 一个简单的购物APP android视频
- 蓝牙遥控小车Android APP
- Android多线程断点续传网络上的音/视频
- 安卓SL4A_R6.APK文件
- android通讯录项目
- Android随手记
- Qt Android 调用JAVA
- android-openGL-canvas-master.zip
- android Socket通信方法与思路
- OpenCV + JavaAndroid 设置ROI
- android mvp模式demo
- BAT大牛深度剖析Android10大开源框架视
- android小程序 标准体重计算器
- android裁剪和人脸识别
- android网易客户端项目源代码
- Android平台下的全景视频播放器配套教
- Android相册
- AndroidStudio个人爱好UI设置
- Android5.0蓝牙开发包
- android之蓝牙编程
- OpenstreetmapAndroid版开发必备库文件
- android架构师开发视频-高级视频教程
- 文件复制及进度条 android 文件复制
- android计算器源码
- fastjson-1.1.34.android.jar最新版本
评论
共有 条评论