[automator学习篇]android 接口-- bluetooth
http://www.android-doc.com/guide/topics/connectivity/bluetooth.html
本地下载的sdk 目录: D:\AndroidSdk\sources\android-25\android\bluetooth,里面提供了很多接口,用来建立蓝牙;
在编译服务器上的目录: /home/liuzhipeng/workspace/AndroidN/android/frameworks/base/core/java/android/bluetooth
1) 开启蓝牙
http://blog.sina.com.cn/s/blog_537d61430101d4tw.html
public class openAndCloseBluetooth {
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
private String logTag = "bluetoothtest";
@Test
public void openBluetooth() throws Exception {
if(mBluetoothAdapter == null){
Log.i(logTag,"device not support bluetooth");
return ;
}
if(!mBluetoothAdapter.isEnabled()){
Log.i(logTag,"start bluetooth");
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
Context context = InstrumentationRegistry.getContext();
context.startActivity(enableBtIntent);
Log.i(logTag,"start bluetooth success");
}
// mBluetoothAdapter.enable();
}
}
这种是弹出对话框的

另外一种是不打开对话框的:
public void openBluetooth() throws Exception {
if(mBluetoothAdapter == null){
Log.i(logTag,"device not support bluetooth");
return ;
}
// if(!mBluetoothAdapter.isEnabled()){
// Log.i(logTag,"start bluetooth");
// Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
// Context context = InstrumentationRegistry.getContext();
// context.startActivity(enableBtIntent);
// Log.i(logTag,"start bluetooth success");
//
// }
mBluetoothAdapter.enable();
}
[automator学习篇]android 接口-- bluetooth的更多相关文章
- ZT android -- 蓝牙 bluetooth (三)搜索蓝牙
android -- 蓝牙 bluetooth (三)搜索蓝牙 分类: Android的原生应用分析 2013-05-31 22:03 2192人阅读 评论(8) 收藏 举报 bluetooth蓝牙s ...
- android -- 蓝牙 bluetooth (三)搜索蓝牙
接上篇打开蓝牙继续,来一起看下蓝牙搜索的流程,触发蓝牙搜索的条件形式上有两种,一是在蓝牙设置界面开启蓝牙会直接开始搜索,另一个是先打开蓝牙开关在进入蓝牙设置界面也会触发搜索,也可能还有其它触发方式,但 ...
- 深入了解Android蓝牙Bluetooth——《进阶篇》
在 [深入了解Android蓝牙Bluetooth--<基础篇>](http://blog.csdn.net/androidstarjack/article/details/6046846 ...
- 深入了解Android蓝牙Bluetooth ——《总结篇》
在我的上两篇博文中解说了有关android蓝牙的认识以及API的相关的介绍,蓝牙BLE的搜索,连接以及读取. 没有了解的童鞋们请參考: 深入了解Android蓝牙Bluetooth--<基础篇& ...
- Android Developer -- Bluetooth篇 开发实例之四 API详解
http://www.open-open.com/lib/view/open1390879771695.html 这篇文章将会详细解析BluetoothAdapter的详细api, 包括隐藏方法, 每 ...
- Android Developer -- Bluetooth篇 开发实例之一 扫描设备
第一步:声明Bluetooth Permissions <!-- 设置蓝牙访问权限 --> <uses-permission android:name="android.p ...
- Android接口和框架学习
Android接口和框架学习 缩写: HAL:HardwareAbstraction Layer.硬件抽象层 CTS:CompatibilityTest Suite,兼容性測试套件 Android让你 ...
- ZT android -- 蓝牙 bluetooth (五)接电话与听音乐
android -- 蓝牙 bluetooth (五)接电话与听音乐 分类: Android的原生应用分析 2013-07-13 20:53 2165人阅读 评论(9) 收藏 举报 蓝牙android ...
- Android动画学习笔记-Android Animation
Android动画学习笔记-Android Animation 3.0以前,android支持两种动画模式,tween animation,frame animation,在android3.0中 ...
随机推荐
- SpringMVC和Spring的配置文件扫描包详解
在Spring整体框架的核心概念中,容器是核心思想,就是用来管理Bean的整个生命周期的,而在一个项目中,容器不一定只有一个,Spring中可以包括多个容器,而且容器有上下层关系,目前最常见的一种场景 ...
- MD5 介绍
MD5(单向散列算法)的全称是Message-Digest Algorithm 5(信息-摘要算法),经MD2.MD3和MD4发展而来.MD5算法的使用不需要支付任何版权费用. MD5功能: 输入任意 ...
- MySQL字符集和排序介绍
客服端字符集: character_set_client utf8mb4连接字符集: character_set_connection utf8mb4数据库字符集: character_set_dat ...
- bat 符号说明
netstat -an|findstr 139 ipconfig/all findstr IP ipconfig/all |findstr 物理地址 定值选行 ipconf ...
- 如何计算支撑向量数(SVs)
申明:转载请注明出处. 支持向量机(SVM)是一个成熟的单分类器,常常用于对比实验中.往往需要统计支持向量数量来比较算法优劣,MATLAB有自带的SVM工具箱,用法如下: [train, test] ...
- (1)Ngixn 编译安装 (版本:1.12.1)
1.创建用户和群组 groupadd nginx 创建一个用户,不允许登陆和不创主目录 useradd -s /sbin/nologin -g nginx -M ngi ...
- iPhone Scrollbars with iScroll
Since we've had web browsers and JavaScript, we've been intent on replacing native browser functiona ...
- javaEE(14)_文件上传下载
一.文件上传概述 1.实现web开发中的文件上传功能,需完成如下二步操作: •在web页面中添加上传输入项•在servlet中读取上传文件的数据,并保存到本地硬盘中. 2.如何在web页面中添加上传输 ...
- rhel7.3smb安装配置
rhel7.3smb安装配置 1.安装 yum -y install samba samba-client cifs-utils 2.配置开机自启动,覆盖原配置文件 systemctl enable ...
- javascript基础知识 (八) BOM学习笔记
一.什么是BOM BOM(Browser Object Model)即浏览器对象模型. BOM提供了独立于内容 而与浏览器窗口进行交互的对象: 由于BOM主要用于管理窗口 ...