2017-03-21 20 views
1

AndroidとMicrosoft Hololensへのアプリケーションを作成しました。そこでは、Bluetooth搭載のGPSデータをAndroid携帯からHololens(Bluetooth LE広告主)に送信することができます大丈夫。しかし、私がHololensからAndroidに他のデータを送信しようとしているとき、私は、これらのデバイスがペアになっているにもかかわらず、Android phoneがHololensを検出できないという問題があります。ホロレンスからのデータをブルートゥースで送信することも可能ですか?それとも私のコードに間違っていますか? Bluetooth LE Advertisingは双方向データ転送をサポートしていますか?AndroidとHololensの間でブルートゥースデータを送信

+0

私は同様の用途を探しています。私は、私のアンドロイドデバイスをホロレンスと接続し、アンドロイドデバイスからホロレン​​スに片道送信したいと考えています。リスナーコードがホロレンス側でどのようにデータを取得するべきかを提案できますか? – Venkatesh

答えて

0

私はあなたのAndroidConnectedスレッドがInputStream(mmInStream)であると推測しています。スレッドの「実行」機能としてこれを試してみてください。

public void run() { 

     System.out.println("BT THREAD RUNNING"); 

     mmBuffer = new byte[1024]; 
     int numBytes; // bytes returned from read() 
     InputStreamReader mmInStreamReader = new InputStreamReader(mmInStream); 
     BufferedReader mmReader = new BufferedReader(mmInStreamReader); 

     // Keep listening to the InputStream until an exception occurs. 

     while (true) { 
      try { 
       // Read from the InputStream. 

       Thread.sleep(100); 
       String s = mmReader.readLine(); 
       Thread.sleep(100); 
       //Static class that handles the response 
       BluetoothCommunications.responseHandler(s); 



      } catch (IOException e) { 
       System.out.println("Input stream was disconnected" + e); 
       main.disconnected(); 
       break; 
      } catch (Exception e) { 
       System.out.println(e.getMessage()); 
      } 
     } 
    } 
関連する問題