Inhand blutooth_client.discoverdevices()报告&quot" nullReferenceException:' object reference未设置为对象的实例。

发布于 2025-02-10 09:37:57 字数 426 浏览 2 评论 0原文

我试图使用inthand.net.bluetooth编写服务器代码和客户端代码,以促进Android手表和Windows之间的通信。但是,该行“ client.discoverdevices();”继续记录以下错误。任何人都可以看看并提供一些帮助吗?如果有人能提供任何帮助,真的很感激。

错误消息是:

system.nullReferenceException:“对象引用未设置为对象的实例。”

发生在线上:

Bluetooth client = new BluetoothClient();
for each (var item in client.DiscoverDevices()) {
    ......
}

使用32feet.net软件包运行PC-PC通信程序时不会发生这样的问题。

I attempted to write the Server code and Client code using inTheHand.Net.Bluetooth to promote communication between android watch and Windows. However, the line "client.DiscoverDevices();" keeps recording the following error. Is it possible for anybody to have a look and give some help? Really appreciate it if anyone can help by any amount.

The error message is:

System.NullReferenceException: 'Object reference not set to an instance of an object.'

Occured at the line:

Bluetooth client = new BluetoothClient();
for each (var item in client.DiscoverDevices()) {
    ......
}

Such a problem will not occur when running PC-PC communication program using 32Feet.net package.

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

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

发布评论

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

评论(2

一生独一 2025-02-17 09:37:57

检查此 link> link in Android com in android。
当应用程序加载时,请勿调用“ new BluetoothClient()”。
当您执行此操作时
加载应用程序后,尝试调用“ new Blueotoothclient()”。

Check this link for any permission on android.
Do not call "new BluetoothClient()" when the application is loading.
when you do this any subsequent call will fail on BluetoothRadio.GetDefault
Try to call "new BlueotoothClient()" after application was loaded.

静待花开 2025-02-17 09:37:57

在初始化Android上的bluetoothclient()之前,您可能需要添加下面的行。

InTheHand.AndroidActivity.CurrentActivity = this.Activity;

​在使用库之前。

you may need to add the line below before you initialise the BluetoothClient() on Android.

InTheHand.AndroidActivity.CurrentActivity = this.Activity;

Note: this.Activity may be fine as just 'this'

I had the same issue and eventualy discovered that you need to set the running activity before using the library.

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