B4A Library ABFlicB4A library for Flic buttons

cute-as-a-button-1.png

You probably have seen these nifty little IoT Flic buttons around. They are a fun and relative cheap BLE button that allows you to do something when the button is clicked, doubleclicked or hold.

Demo video:

How to use:
1. Install the Flic app from the Google Play.
2. On their developer page, create a new app: you get a key and a secret.
3. Copy the ABFlicB4A library jar and xml to your library folder and select it in B4A

Example usage code:
B4X:
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.

End Sub

Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
   Private flic As ABFlic
   Private Button2 As Button
   Private Button3 As Button
   Private Button4 As Button
   Private Label1 As Label
   Private Button1 As Button
   
   Private MyFlicID As String
   
   Private FlicResults As List   
End Sub

Sub Activity_Create(FirstTime As Boolean)
   'Do not forget to load the layout file created with the visual designer. For example:
   Log("created")
   Activity.LoadLayout("1")     
   FlicResults.Initialize
   FlicResults.Add("RESULTACTION_HOLD")
   FlicResults.Add("RESULTACTION_SINGLECLICK")
   FlicResults.Add("RESULTACTION_DOUBLECLICK")
End Sub

Sub Activity_Resume
   ' your key and secret
   flic.Initialize("Flic", "d60d36a0-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "db5c2b3d-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "ABFlicTest")
End Sub

Sub Button1_Click
   flic.ForgetButton(MyFlicID)
End Sub

Sub Button2_Click
   flic.GrabButton
End Sub

Sub Button3_Click
   flic.StartListening
End Sub

Sub Button4_Click
   flic.StopListening
End Sub

Sub flic_Added(buttonID As String, Name As String)
   MyFlicID = buttonID
   Log("Added: " & buttonID)
   Label1.Text = "Added: " & buttonID & CRLF & Label1.Text
End Sub

Sub flic_Clicked(buttonID As String, wasQueued As Boolean, timeDiff As Int)
   MyFlicID = buttonID
   Log("Clicked: " & buttonID)
   Label1.Text = "Clicked: " & buttonID & CRLF & Label1.Text
End Sub

Sub flic_DoubleClicked(buttonID As String, wasQueued As Boolean, timeDiff As Int)
   MyFlicID = buttonID
   Log("DoubleClicked: " & buttonID)
   Label1.Text = "DoubleClicked: " & buttonID & CRLF & Label1.Text
End Sub

Sub flic_Holded(buttonID As String, wasQueued As Boolean, timeDiff As Int)
   MyFlicID = buttonID
   Log("Holded: " & buttonID)
   Label1.Text = "Holded: " & buttonID & CRLF & Label1.Text
End Sub

Sub flic_Removed(buttonID As String)
   MyFlicID = ""
   Log("Removed: " & buttonID)
   Label1.Text = "Removed: " & buttonID & CRLF & Label1.Text
End Sub

Sub flic_Error(err As Int)
   Log("Error: " & err)
   Label1.Text = "Error: " & err & CRLF & Label1.Text
End Sub

I'm currently working on a Desktop/Raspberry Pi version of this library, which I will share in the B4J forum later.
 

Attachments

  • ABFlicB4A1.00.zip
    48.8 KB · Views: 408

biometrics

Active Member
Licensed User
Longtime User
Hi All

Does the flic app have to be installed on the phone for the Lib to work ? We just contacted Flic about using their buttons with some of our apps and they responded with this:

Hi,
Terribly sorry for the very long delay here, this request was missed by me someway.
We have SDK's for both iOS and Android for you to use and implement support for Flic directly into your own apps, is that what you are looking for?
Please find the SDK's here https://github.com/50ButtonsEach/

Do you already have a couple of buttons to test this with?
Let me know if you think this is what you're looking for!

Best,

Ludvig Edlund | Head Of Sales

Ludvig@shortcutlabs.com| M: +46 70 728 61 63



Regards

John.
When I worked on this in 2018 I had to install their app and configure the buttons. Don't know if that is still the case.
 

biometrics

Active Member
Licensed User
Longtime User
Thanks for the reply, did you have success using it ?
Yes it worked fine. But the project didn't proceed beyond the pilot (was used a queuing system at a pharmacy/chemist, they would press the Flic button to call the next client).
 

Jmu5667

Well-Known Member
Licensed User
Longtime User
yes, 4 years ago this was required. They probably have better SDKs now that you can just build in your app.

They sent a link https://github.com/50ButtonsEach/ . We are looking at using that as SOS buttons for one of our apps both Android ans iODS. @tigrot said he tried and gave up. dont want to invest time into something that is not reliable.
 

Jmu5667

Well-Known Member
Licensed User
Longtime User
I have bought some flic, first version, but the company never released the driver for Android for this device. The most useless expense in my life. Batteries without any use discharged in 8 months. They are somewhere, don't know where...

Thanks for the feedback.
 

DonManfred

Expert
Licensed User
Longtime User
Top