[AC-5109] [Hyperloop] Problem calling listenUsingRfcommWithServiceRecord from Bluetooth Adapter
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2017-09-26T16:59:57.000+0000 |
Affected Version/s | Appcelerator Studio 4.5.0 |
Fix Version/s | n/a |
Components | Hyperloop |
Labels | android, bluetooth, hyperloop |
Reporter | Daniel Martinez Fernandez |
Assignee | Shak Hossain |
Created | 2017-07-27T20:21:10.000+0000 |
Updated | 2017-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!
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!
Hello, Please try with the latest SDK 6.1.0.GA and latest Hyperloop 2.1.2. version. Thanks.
[~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:Hello [~dnlmartinezfernandez], Is your issue resolved? please get back to us. Thanks.
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!