android - 蓝牙适配器问题?

标签 android bluetooth

我正在编写以下代码并在“mBtAdapter.startDiscovery();”上遇到一些问题,我无法理解到底发生了什么,我只想启动蓝牙并将设备添加到我的阵列中作为我的应用已加载。

package com.wiztech.veer;

import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.os.Bundle;
import android.widget.ArrayAdapter;

public class BLU_TESTActivity extends Activity {

// Member fields
private BluetoothAdapter mBtAdapter;
private ArrayAdapter<String> mPairedDevicesArrayAdapter;
private ArrayAdapter<String> mNewDevicesArrayAdapter;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    // Get the local Bluetooth adapter
    mBtAdapter = BluetoothAdapter.getDefaultAdapter();
    mBtAdapter.startDiscovery();

}
}

错误是

07-26 13:21:52.178: ERROR/AndroidRuntime(4962): ERROR: thread attach failed
07-26 13:21:53.518: ERROR/ActivityManager(117): fail to set top app changed!
07-26 13:21:53.668: ERROR/AndroidRuntime(4970): ERROR: thread attach failed

请帮忙!

最佳答案

您是否尝试过 broadcastReceiver(),或者您可能缺少 manifest.xml 中的权限。

关于android - 蓝牙适配器问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6826586/

相关文章:

android - 添加 flavor 后将apk上传到现有的Play商店项目

java - 对 SQLiteDatabase 使用单例设计模式

java - 哪种集合类型最适合不断更新、固定大小的字符串数组?

java - 将值从适配器传递到导航组件中的 BottomNavigationView fragment

python - 蓝牙错误(11、资源暂时不可用)

iphone - 蓝牙应用的最佳平台

android - 如何通过 Activity 或服务强制连接到 a2dp 蓝牙设备

android - 如何在node.js中实现没有express服务器的Android Deeplink

android - 找到蓝牙收件箱

android - 简单的蓝牙数据接收器Android