Android的:获取蓝牙SDP服务名称 [英] Android: Get Bluetooth SDP Service Name

查看:912
本文介绍了Android的:获取蓝牙SDP服务名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android的蓝牙API允许您使用注册一个SDP服务:

The Android Bluetooth API allows you to register an SDP service using:

String BLUETOOTH_NAME="MyBluetoothService";
mAdapter.listenUsingRfcommWithServiceRecord(BLUETOOTH_NAME, UUID.fromString(uuid));

它也可以让你启动一个服务Discovey上的远程蓝牙设备,找到现役UUID的名单:

It also allows you to initiate a Service Discovey on a remote Bluetooth Device to find the list of active service UUID's:

device.fetchUuidsWithSdp();

但是,似乎没有可用来获取服务名称的任何公共方法。它可以通过其他途径来获取?

However, there doesn't seem to be any public method available to get the service name. Can it be acquired by other means?

推荐答案

我想你想你会做在Linux中以

I suppose you want to get the names of services running on the device as you would do on a linux box with

浏览的sdptool本地| egrep的服务名称:

sdptool browse local | egrep "Service Name:"

因此​​,答案是否定的,因为没有Android的API方法和命令sdptool是不是在Android上。

So the answer is no, as there is no Android API method and sdptool is not on android.

然而,你可以写AC库使用NDK包含根据功能,并通过JNI调用函数(见蓝牙程序员先上的 http://people.csail.mit.edu/rudolph/Teaching/Articles/BTBook.pdf )。

However you might write a c library containing an according function using the NDK and call the function via JNI (see Bluetooth for Programmers for the first on http://people.csail.mit.edu/rudolph/Teaching/Articles/BTBook.pdf).

顺便说一句:要列出按名称,而不是由UUID的服务为什么。这是我的经验,服务的名称略有不同,实现的UUID时是可信的。

By the way: Why do you want to list the services by name and not by UUID. It is my experience that service names slightly differ with implementations while UUIDS are credible.

这篇关于Android的:获取蓝牙SDP服务名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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