Titanium JIRA Archive
Appcelerator Community (AC)

[AC-5109] [Hyperloop] Problem calling listenUsingRfcommWithServiceRecord from Bluetooth Adapter

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionFixed
Resolution Date2017-09-26T16:59:57.000+0000
Affected Version/sAppcelerator Studio 4.5.0
Fix Version/sn/a
ComponentsHyperloop
Labelsandroid, bluetooth, hyperloop
ReporterDaniel Martinez Fernandez
AssigneeShak Hossain
Created2017-07-27T20:21:10.000+0000
Updated2017-09-26T16:59:57.000+0000

Description

I've been trying to implement a simple Bluetooth module using Hyperloop and I've had problems with some BluetoothAdapter Methods. I'm doing a commonjs module to handle bluetooth stuff on my app, but i'll post only the specific parts that are giving me errors: var BluetoothManager = require('android.bluetooth.BluetoothManager'); var currentActivity = new Activity(Ti.Android.currentActivity); var Context = require('android.content.Context'); var _BluetoothManager = BluetoothManager.cast(currentActivity.getSystemService(Context.BLUETOOTH_SERVICE)); var BluetoothAdapter = _BluetoothManager.getAdapter(); When I try to create BluetoothServerSocket it gives me this error: var BluetoothServerSocket = BluetoothAdapter.listenUsingRfcommWithServiceRecord('TEST', '27bc60d4-366d-c8e4-27ad-106117e6fbaf'); [ERROR] : HyperloopProxy: (main) [16911,16911] Unable to resolve method call. Class: android.bluetooth.BluetoothAdapter, method name: listenUsingRfcommWithServiceRecord, args: ['TEST', '27bc60d4-366d-c8e4-27ad-106117e6fbaf']. I've also try with this method(listenUsingInsecureRfcommWithServiceRecord), with no success. I'm following the Bluetooth Adapter spec https://developer.android.com/reference/android/bluetooth/BluetoothAdapter.html, but maybe I'm missing something. Thx for your time!

Comments

  1. Daniel Martinez Fernandez 2017-07-27

    It seems I made a mistake for posting this on appcelerator project instead of Titanium, but I don't seem to have the permission to create a bug on Titanium project. Can you help me moving the issue to the correct project, or, if it's not possible, helping me with my account so I can post this on TIMOB. Thx!
  2. Sharif AbuDarda 2017-07-31

    Hello, Please try with the latest SDK 6.1.0.GA and latest Hyperloop 2.1.2. version. Thanks.
  3. Jan Vennemann 2017-08-03

    [~dnlmartinezfernandez], the signature is listenUsingRfcommWithServiceRecord (String name, UUID uuid) but you are passing two strings, which might be the issue why it can't find the method. Try this:
       var UUID = require('java.util.UUID');
       var bluetoothServerSocket = BluetoothAdapter.listenUsingRfcommWithServiceRecord('TEST', UUID.fromString('27bc60d4-366d-c8e4-27ad-106117e6fbaf');
       
  4. Sharif AbuDarda 2017-08-29

    Hello [~dnlmartinezfernandez], Is your issue resolved? please get back to us. Thanks.
  5. Daniel Martinez Fernandez 2017-08-29

    Hello, sorry for the late response, I forgot to test this as I resolved the bluetooth issue making an android module. I just tested @Jan Vennemann solution and it's working now, need to pay more attention on those parameter types :S. Thank you for your help!

JSON Source