如何启用/ android的编程方式禁用蓝牙 [英] How to enable/disable bluetooth programmatically in android

查看:230
本文介绍了如何启用/ android的编程方式禁用蓝牙的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我想启用通过program..I /关闭蓝牙具有以下code。

I want to enable/disable bluetooth through the program..I has the following code.

BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();    
if (!mBluetoothAdapter.isEnabled()) {
        Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
        startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);

不过,这样的code不是工作在SDK 1.5..How我可以做同样的SDK 1.5。?

But this sort of code is not working in SDK 1.5..How can i do the same in SDK 1.5.?

推荐答案

Android的<一个href="http://developer.android.com/reference/android/bluetooth/BluetoothAdapter.html">BluetoothAdapter文档说,因为API级别5 API级别就已经包括了5 是Android 2.0的。

Android BluetoothAdapter docs say it has been available since API Level 5. API Level 5 is Android 2.0.

您可以尝试使用蓝牙API的一个补丁包(还没有尝试过亲自):<一href="http://$c$c.google.com/p/backport-android-bluetooth/">http://$c$c.google.com/p/backport-android-bluetooth/

You can try using a backport of the Bluetooth API (have not tried it personally): http://code.google.com/p/backport-android-bluetooth/

这篇关于如何启用/ android的编程方式禁用蓝牙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆