Trigger cancel event on ABZxing

joneden

Active Member
Licensed User
Longtime User
Hi All,

I'm using the ABZxing lib and it's great however in the event that there has been no barcode detected for x seconds I want to return control to my app. I can do this with a kiosk method.

The problem that I have is that although the control returns to the app, the call to the ZXing lib seems to be still active. Thus the second call that is made opens a second instance.

How do I either trigger the cancel event or kill the call when returning to my app?

Regards,

Jon
 

mc73

Well-Known Member
Licensed User
Longtime User
In the documentation I see a cancel event. I haven't tried this lib yet, but couldn't you perhaps send a 'cancel' so that this event is triggered, thus unloading the instance properly?
 
Upvote 0

joneden

Active Member
Licensed User
Longtime User
Good idea. How do you raise an event in B4A? It's not something I've had to do yet!

Looking through the forum it seems to have info on raising an event from a lib or by way of some exposed code built into libraries but nothing of this type - I hope I'm wrong!

Regards,

Jon
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
Unfortunately, you're not wrong. From what I saw, zxing lib is using an external app to scan. You cannot send a keystroke to an external app.
This leads to the other scenario, that is to kill the app which handles scanning. For this, perhaps you should check the OS lib.
 
Upvote 0

joneden

Active Member
Licensed User
Longtime User
mmm I've been trying to kill the app with the following code:

B4X:
Dim objOperatingSystem As OperatingSystem : objOperatingSystem.Initialize("objOperatingSystem")
    Dim lstProcessNames As List : lstProcessNames.Initialize
    Dim lstProcessIds As List : lstProcessIds.Initialize
    Dim lstProcessNamePids As List : lstProcessNamePids.Initialize
      Dim lstProcessReturn As List = objOperatingSystem.RunningAppProcessInfo( lstProcessNames,  lstProcessIds,  lstProcessNamePids )
    Dim i  As Int
    For i = 0 To lstProcessNames.Size - 1
      Dim processName As String = lstProcessNames.Get(i)
      If processName.IndexOf("zxing")>-1 Then
            objOperatingSystem.killProcess( lstProcessIds.Get(i))
        End If
    Next

The code runs fine and hits the killProcess command just fine. Nothing happens though :( When I exit the app the scanner is still working in the background.

I wondered if there was a way to send a cancel message via an intent but it looks like you can't do that.

Hmmm.
 
Upvote 0

joneden

Active Member
Licensed User
Longtime User
Help still needed :(

Hi All,

I've been on other stuff and back in this issue (in previous post). I still haven't been able to resolve.

Can anyone help?

Regards,

Jon
 
Upvote 0

AndyDroid2012

Member
Licensed User
Longtime User
If you can't solve the problem, change the problem.
Instead of calling the scanner Zxing can you make visible a large button
in the view with the legend saying

"Click button to scan" ... which fires Zxing

if no click within a timer period 5 secs the user is not ready to scan, so fall through to the next part of your program.

I am assuming there is a human involved and this is not an unattended scanner app.
 
Upvote 0
Top