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的更多相关文章

  1. ZT android -- 蓝牙 bluetooth (三)搜索蓝牙

    android -- 蓝牙 bluetooth (三)搜索蓝牙 分类: Android的原生应用分析 2013-05-31 22:03 2192人阅读 评论(8) 收藏 举报 bluetooth蓝牙s ...

  2. android -- 蓝牙 bluetooth (三)搜索蓝牙

    接上篇打开蓝牙继续,来一起看下蓝牙搜索的流程,触发蓝牙搜索的条件形式上有两种,一是在蓝牙设置界面开启蓝牙会直接开始搜索,另一个是先打开蓝牙开关在进入蓝牙设置界面也会触发搜索,也可能还有其它触发方式,但 ...

  3. 深入了解Android蓝牙Bluetooth——《进阶篇》

    在 [深入了解Android蓝牙Bluetooth--<基础篇>](http://blog.csdn.net/androidstarjack/article/details/6046846 ...

  4. 深入了解Android蓝牙Bluetooth ——《总结篇》

    在我的上两篇博文中解说了有关android蓝牙的认识以及API的相关的介绍,蓝牙BLE的搜索,连接以及读取. 没有了解的童鞋们请參考: 深入了解Android蓝牙Bluetooth--<基础篇& ...

  5. Android Developer -- Bluetooth篇 开发实例之四 API详解

    http://www.open-open.com/lib/view/open1390879771695.html 这篇文章将会详细解析BluetoothAdapter的详细api, 包括隐藏方法, 每 ...

  6. Android Developer -- Bluetooth篇 开发实例之一 扫描设备

    第一步:声明Bluetooth Permissions <!-- 设置蓝牙访问权限 --> <uses-permission android:name="android.p ...

  7. Android接口和框架学习

    Android接口和框架学习 缩写: HAL:HardwareAbstraction Layer.硬件抽象层 CTS:CompatibilityTest Suite,兼容性測试套件 Android让你 ...

  8. ZT android -- 蓝牙 bluetooth (五)接电话与听音乐

    android -- 蓝牙 bluetooth (五)接电话与听音乐 分类: Android的原生应用分析 2013-07-13 20:53 2165人阅读 评论(9) 收藏 举报 蓝牙android ...

  9. Android动画学习笔记-Android Animation

    Android动画学习笔记-Android Animation   3.0以前,android支持两种动画模式,tween animation,frame animation,在android3.0中 ...

随机推荐

  1. VS2015 VB.Net利用QrCodeNet生成QR Code

    Step by step Create QR Code with QrCodeNet Step.1 新建項目 Step.2 下載QrCodeNet代碼,解壓\QrCodeNet\sourceCode\ ...

  2. Java 8新特性--Lambda表达式作为返回值

    lambda表达式作为方法的返回值:

  3. GIMP 无法设置中文的问题解决

    首先按照网上说的安装了language-pack-gnome-zh-hant 参考链接:http://www.ubuntu-tw.org/modules/newbb/viewtopic.php?top ...

  4. 精仿百思不得姐客户端应用iOS源码

    XFBaiSiBuDeJie 高仿百思不得姐客户端 初次学习使用RAC,还不是怎么熟悉,使用的仍是MVC模式,MVVM还在摸索中... 如果大家觉得还不错,请给颗星星支持下~~~ 程序中使用到的库 A ...

  5. shiro 配置拦截规则之后css和js等失效

    使用shiro作为平台的权限管理工具,shiro的配置文件如下: package com.ros.config; import java.util.LinkedHashMap;import java. ...

  6. JAVA 数据库编程中的性能优化

    1. 禁止自动提交:在默认情况下,程序执行的任何sql 语句都是自动提交的向一个表中插入2000条记录,自动提交所用的时间  11666毫秒禁止自动提交(显示提交) 3450毫秒 2. 批处理:多用批 ...

  7. block总结我的

    1) struct Block_descriptor { unsigned long int reserved; unsigned long int size; void (*copy)(void * ...

  8. NSCopying协议和copy方法

    不是所有的对象都支持 copy需要继承NSCopying 协议(实现 copyWithZone: 方法)同样,需要继承NSMutableCopying 协议才可以使用mutableCopy(实现 mu ...

  9. keras中的shape/input_shape

    在keras中,数据是以张量的形式表示的,张量的形状称之为shape,表示从最外层向量逐步到达最底层向量的降维解包过程.“维”的也叫“阶”,形状指的是维度数和每维的大小.比如,一个一阶的张量[1,2, ...

  10. canvas 在视频中的用法

    <!doctype html> <html> <head> <meta charset="UTF-8"> <title> ...