没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
android and buletooth HC-05 connect
//author Engineer-Tang,I take two month finish this
program, it vrey useful;I am so happy;
//welcome give more advise,critical.
package com.internet.bluetooth_4;
import java.io.IOException;
import BusinessBluetooth.BusinessBluetooth;
import
BusinessBluetooth.BusinessBluetooth.OnportListener;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends Activity implements
OnClickListener,OnportListener {
EditText edtMessage;
Button btnsend;
private TextView tvresult;
BusinessBluetooth m_BusinessBluethooth;
private Context mContext;
private Handler Handler=new Handler(){
public void handleMessage (android.os.Message msg){
switch(msg.what){
case 0x0001:
String index = (String) msg.obj;
tvresult.setText("接收的数据"+index);
break;
}
};
};
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
InitView();
InitListener();
m_BusinessBluethooth=new
BusinessBluetooth(this);
m_BusinessBluethooth.CreatePortLinsten();
}
private void InitView(){
edtMessage=(EditText)findViewById(R.id.edtMessage
);
btnsend=(Button)findViewById(R.id.btnSend);
}
private void InitListener(){
btnsend.setOnClickListener(this);
tvresult=(TextView)findViewById(R.id.tvresult);
}
@Override
public void onClick(View v){
switch (v.getId()){
case R.id.btnSend:
new Thread(){
public void run(){
Message msg=new Message();
msg.what=0x0001;
msg.obj=m_BusinessBluethooth.add2;
Handler.sendMessage(msg);
};
}.start();
break;
}
}
剩余18页未读,继续阅读
资源评论
xxpr_ybgg
- 粉丝: 6431
- 资源: 3万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功