没有合适的资源?快使用搜索试试~ 我知道了~
本文实例为大家分享了Android实现蓝牙原理代码,供大家参考,具体内容如下 package com.example.se7en.testbluetooth; import android.app.Activity; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothServerSocket; import android.bluetooth.BluetoothSocket; import android.
资源详情
资源评论
资源推荐
蓝牙原理蓝牙原理Android代码实现代码实现
本文实例为大家分享了Android实现蓝牙原理代码,供大家参考,具体内容如下
package com.example.se7en.testbluetooth;
import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothServerSocket;
import android.bluetooth.BluetoothSocket;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Toast;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class MainActivity extends Activity
{
private BluetoothAdapter adapter;
private MyReceiver receiver;
private ListView mListView;
private List<BluetoothDevice> mDevices;
private com.example.se7en.testbluetooth.DeviceAdapter mDeviceAdapter;
private BluetoothSocket mSocket;
private EditText et;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mListView = (ListView) findViewById(R.id.lv);
et = (EditText) findViewById(R.id.et);
adapter = BluetoothAdapter.getDefaultAdapter();
BlueToothHandler.getInstance().setContext(this);
init();
}
private void init()
{
initListView();
// 判断是否支持蓝牙功能
if (adapter == null)
{
Toast.makeText(this, "该手机不支持蓝牙功能", Toast.LENGTH_LONG).show();
return;
}
// 判断蓝牙功能是否打开
if (!adapter.isEnabled())
{
weixin_38704011
- 粉丝: 3
- 资源: 947
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0