Android Question SOLVED Barcode scanner service

nibbo

Active Member
Licensed User
Longtime User
Hi all

I have a handheld device with a built in barcode scanner.
It seems to work just fine for a few hours and then starts failing to scan; it is almost as if the service intent is not starting?
Below is the service code:

B4X:
#Region  Service Attributes
#StartAtBoot: False
#End Region

Sub Process_Globals
End Sub

Sub Service_Create
End Sub

Sub Service_Start (StartingIntent As Intent)
    If StartingIntent.HasExtra("barcode_string") Then
        '    see if we have a code
        Dim sCode As String = StartingIntent.GetExtra("barcode_string")
        '    pass back to stock movement activity
        CallSubDelayed2(MoveStock, "BarcodeScanned", sCode)
    End If
    Service.StopAutomaticForeground
End Sub

Sub Service_Destroy
End Sub

Here is the Manifest additions:

B4X:
AddReceiverText(CodeScanned,
                <intent-filter>
                <action android:name="android.intent.ACTION_DECODE_DATA" />
                <category android:name="android.intent.category.DEFAULT" />
                </intent-filter>)

As said, the BarcodeScanned sub is called as expected for quite a while before it stops working, no errors or anything.
The first thing the BarcodeScanned sub does is makes an audible beep which we don't hear so I am guessing the service does not get invoked at all...
Even more odd is rebooting the device does not always fix it straight away, it can take several reboots and even a battery removal to get the thing back into life.

Is there a problem starting the same service via intents multiple times? Am I stopping it correctly? Anyone got any ideas?

Thanks
 

nibbo

Active Member
Licensed User
Longtime User
You are testing it in release mode, right?

Hi Erel, unfortunately I cannot reproduce this in testing, it is an error encountered by the users in live on a couple of handhelds.
Next time it happens I will see if carries on failing after I connect via B4A bridge with release logging.
Thanks
 
Upvote 0

nibbo

Active Member
Licensed User
Longtime User
OMG, I wont say what it was, it is too embarrassing :oops:
Thanks Erel, I keep forgetting the #BridgeLogger option, very useful in this instance.
 
Upvote 0
Top