Accessing Android List with Nativescript

133 Views Asked by At

The Short

I am trying to create a List<ScanFilter> in JavaScript by accessing Android API, as shown below:

var scanFilterList = new java.util.List<android.bluetooth.le.ScanFilter>;

However, JavaScript gives me a SyntaxError due to an unexpected token, which I presume is because of the angle brackets. Any assistance in overcoming this problem and creating a List<ScanFilter> would be greatly appreciated!!

The Long

I want to periodically run BluetoothLE scans in my NativeScript application (only worrying about the android side for the moment), even while the screen is turned off. To my understanding this would be possible, as stated in the documentation:

For unfiltered scans, scanning is stopped on screen off to save power. Scanning is resumed when screen is turned on again. To avoid this, do filtered scanning by using proper ScanFilter. Source

I am attempting to create a ScanFilter to be used as a parameter for startScan() when it is called. However, when I try to create a new List as shown below:

var scanFilterList = new java.util.List<android.bluetooth.le.ScanFilter>;

I get a SyntaxError due to an unexpected token. I am assuming this is because the angle-brackets aren't recognized by JavaScript and cause problems.

How can I bypass this problem and successfully create a List<ScanFilter> variable in JavaScript for use.

0

There are 0 best solutions below