[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中 ...
随机推荐
- CF1025B Weakened Common Divisor
思路: 首先选取任意一对数(a, b),分别将a,b进行因子分解得到两个因子集合然后取并集(无需计算所有可能的因子,只需得到不同的质因子即可),之后再暴力一一枚举该集合中的元素是否满足条件. 时间复杂 ...
- 打造自己的JavaScript武器库
自己打造一把趁手的武器,高效率完成前端业务代码. 前言 作为战斗在业务一线的前端,要想少加班,就要想办法提高工作效率.这里提一个小点,我们在业务开发过程中,经常会重复用到日期格式化.url参数转对象. ...
- python GIL锁问题
一.GIL是什么 官方解释: In CPython, the global interpreter lock, or GIL, is a mutex that prevents multiple na ...
- Spring 配置定时器(注解+xml)方式—整理
一.注解方式 1. 在Spring的配置文件ApplicationContext.xml,首先添加命名空间 xmlns:task="http://www.springframework.or ...
- 洛谷 P2617 Dynamic Ranking
题目描述 给定一个含有n个数的序列a[1],a[2],a[3]……a[n],程序必须回答这样的询问:对于给定的i,j,k,在a[i],a[i+1],a[i+2]……a[j]中第k小的数是多少(1≤k≤ ...
- (五)mybatis之下载与基本构成
1. 下载MyBatis. 输入网址:https://github.com/mybatis/mybatis-3/releases 进入Mybatis下载页面,选择第一个选项,然后就可以加载到myba ...
- SAP Cloud for Customer(C4C)的一些学习资料
经常有顾问朋友们问我想自学C4C,有什么好的资料. SAP内部确实有一些C4C培训材料,但是不能散布到公司外部. 想学习C4C,还是得到SAP官网网站上查找资料. 1. 登录https://help. ...
- java项目指向maven进行构建方式
1.在需要运行的机器中环境变量中配置maven 运行setting 4 配置环境变量 2.运行项目进行重新构建:alt+F5
- 在行列都排好序的矩阵中找数 【题目】 给定一个有N*M的整型矩阵matrix和一个整数K, matrix的每一行和每一 列都是排好序的。实现一个函数,判断K 是否在matrix中。 例如: 0 1 2 5 2 3 4 7 4 4 4 8 5 7 7 9 如果K为7,返回true;如果K为6,返 回false。 【要求】 时间复杂度为O(N+M),额外空间复杂度为O(1)。
从对角考虑 package my_basic.class_3; /** * 从对角开始 */ public class Code_09_FindNumInSortedMatrix { public s ...
- C#获得DataTable的key值
//获得dataTable的key值 List<string> keyList = new List<string>(); ; i < dt.Columns.Count; ...