私は自分のBluetoothデバイスでサポートされているサービスを取得したいモジュールが1つあるアプリケーションを作成しています...現在、UUIDを取得する方法を見つけていないため、リモートデバイスのUUIDを取得できます自分のデバイスの。
前もって感謝します
最後に、多くの苦労の末、自分のBluetoothデバイスのUUIDを見つける方法を見つけました。Sdptool は、Bluetooth デバイスで SDP クエリを実行し、ローカル sdpd を管理するためのインターフェイスを提供します。コード スニペットは次のとおりです。このコードは、ルート アクセス権を持つデバイスでのみ機能します。
try { System.setOut(new PrintStream(new FileOutputStream("/mnt/sdcard/abc.txt"))); System.out.println("HelloWorld1"); Process p; p = Runtime.getRuntime().exec(new String[] { "su", "-c","sdptool", "browse", "local" }); BufferedReader stdInput = new BufferedReader(new InputStreamReader( p.getInputStream())); String s; String res = ""; while ((s = stdInput.readLine()) != null) { if(s.contains("")) System.out.println(s); Log.e("above -----", s); } p.destroy(); return res; } catch (Exception e) { e.printStackTrace(); }
別の Bluetooth デバイスのサービスを検出する場合は、「ローカル」をリモート デバイスの MAC アドレスに置き換えることができます。
または、次のように sdp ツールを使用して inf adb シェルを実行することもできます。
adb shell sdptool ブラウズ ローカル