My first challenge is an external to check if BT is enabled in Android.
Heather (kindly enough) has provided some code but I'm getting an error which I don't know how to fix and even worst I don't know where can I look for help. It seems to be a problem with the parameter definition of one of the calls (as described below) but since I wasn't able to learn how the definition should be I'm in a dead lock.
So, this is the code
Code: Select all
library community.livecode.ss.btstatus
metadata title is "BT Status"
metadata author is "SS"
metadata version is "1.0.0"
use com.livecode.foreign
use com.livecode.java
foreign handler JavaGetDefaultBluetoothAdapter() returns JObject binds to "java:android.bluetooth.BluetoothAdapter>getDefaultAdapter()Landroid/bluetooth/BluetoothAdapter;!static"
foreign handler JavaCheckIfBluetoothIsEnabled() returns JBoolean binds to "java:android.bluetooth.BluetoothAdapter>isEnabled()Z"
public handler CheckIfBluetoothIsEnabled() returns Boolean
unsafe
variable tBluetoothAdapter as JObject
put JavaGetDefaultBluetoothAdapter() into tBluetoothAdapter
variable tIsEnabled as Boolean
put JavaCheckIfBluetoothIsEnabled(tBluetoothAdapter) into tIsEnabled
return tIsEnabled
end unsafe
end handler
end library
if I replace9:59 AM: Compiling module /Users/simonschvartzman/Desktop/SegnaPunto/Externals/BTStatus/BTStatus.lcb
9:59 AM: Error: on line 19 ():
9:59 AM: Error: /Users/simonschvartzman/Desktop/SegnaPunto/Externals/BTStatus/BTStatus.lcb:19:7: error: Too many arguments for specified handler
put JavaCheckIfBluetoothIsEnabled(tBluetoothAdapter) into tIsEnabled
^
9:59 AM: Error: failed to compile module
9:59 AM: Error: Could not compile module /Users/simonschvartzman/Desktop/SegnaPunto/Externals/BTStatus
Code: Select all
put JavaCheckIfBluetoothIsEnabled(tBluetoothAdapter) into tIsEnabled
Code: Select all
put JavaCheckIfBluetoothIsEnabled() into tIsEnabled
So my questions are:
- where can I find the arguments I should be using ?
- where can I learn about how binds are to be defined, I mean for example why in one of the definition it goes:
and in the other
>isEnabled()Z"
What the !static and Z mean ?
Many thanks in advance for any help