蓝牙适配器问题?

发布于 2024-11-26 08:14:05 字数 1110 浏览 0 评论 0原文

我只是编写以下代码并在“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

请帮助!

I am just writing the following code and getting some issue on "mBtAdapter.startDiscovery();", I can't understand what the hell is going on, I just want to start bluetooth and add devices to my array as my app is loaded.

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();

}
}

The errors are

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

Please Help !

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

〃温暖了心ぐ 2024-12-03 08:14:07

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

Have u tried broadcastReceiver(), or u may missing permissions in manifest.xml.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文