Android的监听无连接的UUID [英] Android listen for connections without UUID

查看:234
本文介绍了Android的监听无连接的UUID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了使用蓝牙传输数据的安卓游戏。我从附带ADK蓝牙聊天应用程序复制到code。我的手机似乎并没有能够与UUID连接,所以我想用另一个方法来取代它。我已经取代我用

I have written an Android game that uses Bluetooth to transfer data. I copied the code from the Bluetooth Chat application that comes with the ADK. My phone doesn't seem to be able to connect with UUID so I would like to replace it with another methods. I have already replaced my connecting methods with

Method m = device.getClass().getMethod("createRfcommSocket", new Class[] {int.class});
tmp = (BluetoothSocket) m.invoke(device, 1);

和现在我不知道我怎么能听那种连接?目前,有读

and now I wonder how I can listen for that kind of connections? Currently there reads

tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE,MY_UUID_SECURE);

,但这显然需要被发送的UUID。

but this obviously requires the UUID to be sent.

推荐答案

感谢史密斯先生提供给我一个答案。随着一点点的研究,我能找到的另一个<一个href=\"http://stackoverflow.com/questions/6480480/rfcomm-connection-between-two-android-devices\">StackOverflow同样的主题和问题 <一个href=\"http://$c$c.google.com/p/android-bluetooth/source/browse/branches/two_dot_o/AndroidBluetoothLibrary/src/it/gerdavax/easybluetooth/LocalDevice2Impl.java?r=58\"相对=nofollow>与我一直在寻找soluction的良好来源文件。

Thanks for Mister Smith by providing me with an answer. With a little research I was able to find an another StackOverflow question with the same subject and a good source file with the soluction I was looking for.

什么我基本上做的是与私人BluetoothAdapter适配器= BluetoothAdapter.getDefaultAdapter()来获得BluetoothAdapter; ,然后用

What I basically had to do is to get the BluetoothAdapter with private BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); and then listen for connections with

Method m = adapter.getClass().getMethod("listenUsingRfcommOn", new Class[] { int.class });
BluetoothServerSocket tmp = (BluetoothServerSocket) m.invoke(adapter, 1);

这篇关于Android的监听无连接的UUID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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