android中的蓝牙连接

时间:2012-06-07 15:29:27

标签: android bluetooth insecure-connection

我正在开发一款Android游戏(目标API - 8),它可以通过蓝牙从两个Android手机播放。由于我的应用程序是针对API级别8(Android版本2.2),我不能去不安全的连接。但我不希望用户干预配对设备。我找到了几个指向http://mobisocial.stanford.edu/news/2011/03/bluetooth-reflection-and-legacy-nfc/的答案。现在我对蓝牙连接有几个问题。

1)博客中提供的解决方案是否可以安全使用?它会引起任何其他问题吗?它是否适用于所有版本的android(除了ICS,它有不安全的蓝牙连接问题)??

2)我们可以在我们的应用程序中创建多个BluetoothSocket对象吗?基本上我正在尝试的是:(参考BluetoothChat演示)

(i)在AcceptThread中 - run()方法

       // Listen to the server socket if we're not connected
        while (mState != STATE_CONNECTED) {
            try {
                // This is a blocking call and will only return on a
                // successful connection or an exception

            <**Go for InsecureBluetooth connection as mentioned in the blog**>
          }catch(IOException e)
          {

                 try {
                // This is a blocking call and will only return on a
                // successful connection or an exception

                <**Go for default secure connection**>
                }catch(IOException e)
               {

               } //next level catch
          }//top level catch
        }//while

如果可能,请告诉我。

0 个答案:

没有答案