Finally after a lot of struggling i found a way to find the services of own bluetooth device. Sdptool provides the interface for performing SDP queries on Bluetooth devices, and administering a local sdpd. Code snippet for it is follows:This code will only work in devices with root access.
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(); }
and in case you want to discover the services of another Bluetooth device then you can replace "local" with the MAC address of the remote device.
Or you can also try running the sdp tool usinf adb shell as follows:
> adb shell sdptool browse local