[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中 ...
随机推荐
- VS2015 VB.Net利用QrCodeNet生成QR Code
Step by step Create QR Code with QrCodeNet Step.1 新建項目 Step.2 下載QrCodeNet代碼,解壓\QrCodeNet\sourceCode\ ...
- Java 8新特性--Lambda表达式作为返回值
lambda表达式作为方法的返回值:
- GIMP 无法设置中文的问题解决
首先按照网上说的安装了language-pack-gnome-zh-hant 参考链接:http://www.ubuntu-tw.org/modules/newbb/viewtopic.php?top ...
- 精仿百思不得姐客户端应用iOS源码
XFBaiSiBuDeJie 高仿百思不得姐客户端 初次学习使用RAC,还不是怎么熟悉,使用的仍是MVC模式,MVVM还在摸索中... 如果大家觉得还不错,请给颗星星支持下~~~ 程序中使用到的库 A ...
- shiro 配置拦截规则之后css和js等失效
使用shiro作为平台的权限管理工具,shiro的配置文件如下: package com.ros.config; import java.util.LinkedHashMap;import java. ...
- JAVA 数据库编程中的性能优化
1. 禁止自动提交:在默认情况下,程序执行的任何sql 语句都是自动提交的向一个表中插入2000条记录,自动提交所用的时间 11666毫秒禁止自动提交(显示提交) 3450毫秒 2. 批处理:多用批 ...
- block总结我的
1) struct Block_descriptor { unsigned long int reserved; unsigned long int size; void (*copy)(void * ...
- NSCopying协议和copy方法
不是所有的对象都支持 copy需要继承NSCopying 协议(实现 copyWithZone: 方法)同样,需要继承NSMutableCopying 协议才可以使用mutableCopy(实现 mu ...
- keras中的shape/input_shape
在keras中,数据是以张量的形式表示的,张量的形状称之为shape,表示从最外层向量逐步到达最底层向量的降维解包过程.“维”的也叫“阶”,形状指的是维度数和每维的大小.比如,一个一阶的张量[1,2, ...
- canvas 在视频中的用法
<!doctype html> <html> <head> <meta charset="UTF-8"> <title> ...