android – E / BluetoothAdapter(883):蓝牙绑定器为空

答案: How to use Bluetooth in Android emulator?

我试图启用禁用蓝牙设备.出于这个原因,我写了下面的代码,但它给出了错误,也在下面.

if ( bluetoothAdmin == null ) {

    return ;
}
if ( bluetooth . isEnabled()){
    bluetooth . disable ();
}
else {
    bluetooth . enable();
}

在创造

BLuetoothAdapter bluetooth = BluetoothAdapter.getDefaultAdapter() ;

在manisfest

<uses-permission
    android:name="android.permission.BLUetoOTH" 
/>
<uses-permission
    android:name="android.permission.BLUetoOTH_ADMIN" 
/>

错误

01-23 07:18:53.167: E/BluetoothAdapter(883): Bluetooth binder is null

堆栈的一半:

01-23 07:36:55.624: E/SurfaceFlinger(36): ro.sf.lcd_density must be defined as a build property
01-23 07:37:16.954: E/ActivityThread(642): Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d51230 that was originally bound here
01-23 07:37:16.954: E/ActivityThread(642): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d51230 that was originally bound here
01-23 07:37:16.954: E/ActivityThread(642):  at android.app.LoadedApk$Servicedispatcher.<init>(LoadedApk.java:969)
01-23 07:37:16.954: E/ActivityThread(642):  at android.app.LoadedApk.getServicedispatcher(LoadedApk.java:863)
01-23 07:37:16.954: E/ActivityThread(642):  at android.app.ContextImpl.bindService(ContextImpl.java:1418)
01-23 07:37:16.954: E/ActivityThread(642):  at android.app.ContextImpl.bindService(ContextImpl.java:1407)
01-23 07:37:16.954: E/ActivityThread(642):  at android.content.Contextwrapper.bindService(Contextwrapper.java:473)
01-23 07:37:16.954: E/ActivityThread(642):  at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
01-23 07:37:16.954: E/ActivityThread(642):  at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
01-23 07:37:16.954: E/ActivityThread(642):  at com.android.emailcommon.service.AccountServiceProxy.getdeviceid(AccountServiceProxy.java:11    6)
01-23 07:37:16.954: E/ActivityThread(642):  at com.android.exchange.ExchangeService.getdeviceid(ExchangeService.java:1249)
01-23 07:37:16.954: E/ActivityThread(642):  at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1856)
01-23 07:37:16.954: E/ActivityThread(642):  at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
01-23 07:37:16.954: E/ActivityThread(642):  at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
01-23 07:37:16.954: E/ActivityThread(642):  at android.os.AsyncTask$2.call(AsyncTask.java:287)
01-23 07:37:16.954: E/ActivityThread(642):  at java.util.concurrent.FutureTask.run(FutureTask.java:234)
01-23 07:37:16.954: E/ActivityThread(642):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
01-23 07:37:16.954: E/ActivityThread(642):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
01-23 07:37:16.954: E/ActivityThread(642):  at java.lang.Thread.run(Thread.java:856)
01-23 07:37:16.964: E/StrictMode(642): null
01-23 07:37:16.964: E/StrictMode(642): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d51230 that was originally bound here

我在Android模拟器上测试

解决方法

模拟器不支持sdk的文档中提到的蓝牙.你必须在真实设备中检查这个..

你得到错误蓝牙绑定器是空的.这意味着模拟器没有蓝牙功能.

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...