zoukankan      html  css  js  c++  java
  • 蓝牙通讯神器

    下载地址:http://download.csdn.net/detail/yoyo_newbie/8799549


    实例代码:

    		//初始化SamBluetoothManager,可在application初始化
    		SamBluetoothManager.getInstance().init(this);
    		
    		//设置连接,记住配置UUID
    		SamBluetoothManager.getInstance().connectBluetoothDevice(address, UUID, this);
    		
    		//设置心跳为2秒,不设置默觉得3秒
    		SamBluetoothManager.getInstance().setHeartBeat(2*1000);
    		
    		
    		//监听心跳信息
    		SamBluetoothManager.getInstance().setHeartbeatListener(new SamBluetoothManager.HeartbeatListener() {
    			
    			@Override
    			public void outline() {
    				nameView.setText(address+"正在重练。。

    "); stateView.setText(address+"离线"); //重练 SamBluetoothManager.getInstance().reConnect(BluetoothActivity.this); } @Override public void online() { //在线中... nameView.setText(address+"连接成功!"); stateView.setText(address+"在线"); } }); // //发送一条信息 // SamBluetoothManager.getInstance().sendMessage("ddd", new SamBluetoothManager.SendMessageCallback() { // // @Override // public void onFinished(boolean isSuccessfull) { // //isSuccessfull 是否发送成功 // } // }); //设置监听信息 SamBluetoothManager.getInstance().setOnRecieveListener(new SamBluetoothManager.OnRecieveListener() { @Override public void getData(byte[] data, int len) { String result =new String(data,0, len); stateView.setText("收到一条信息:"+result); } });




  • 相关阅读:
    django 母版与继承
    django 模板系统
    及时从数据库中取得数据填放进Form表单的多选框中
    django 自带的验证功能
    django Form表单
    AJAX 操作
    django 中间件
    JVM-crash查看hs_err_pid.log日志
    java-log4j日志打印
    tomcat 闪退问题排查
  • 原文地址:https://www.cnblogs.com/brucemengbm/p/6718070.html
Copyright © 2011-2022 走看看