Android Question Zebra Barcode Scanner and Receiver Module not working

techgreyeye

Member
Licensed User
Longtime User
Hello !

I recently updated one of my apps to target SDK 34 to avoid so many warnings when customers are installing the app. I had to make various changes, but I am left with one unresolved issue.
One customer with a newer Zebra running Android 14 had scanning stop working, and I don't have access to a newer device for debugging (I still have a TC20 running Android 8.1).
Having looked on the forums, I decided to process the intents using a Receiver module rather than a Service using BroadcastReceiver. I am not receiving any barcode scans in the Receiver module.

I've attached a minimal project showing the issue. There is a variable useService in Main which can be set to true or false.

The intent on the Zebra is configured as it is because the app was initially written by somebody else who copied an example and released it without changing them. Could the naming be the issue? Am I missing something from the manifest?

I'd really appreciate if anyone could have a look and see where it is going wrong.

Thank you :)
 

Attachments

  • ZebraApp.zip
    10.1 KB · Views: 15

techgreyeye

Member
Licensed User
Longtime User
Can you post the relevant code?

Have you checked the device documentation? Maybe it only works with dynamic intent filters.

Hi Erel,

Service using BroadcastReceiver:
#Region  Service Attributes
    #StartAtBoot: False
    
#End Region

' 401

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim BC As BroadCastReceiver

End Sub

Sub Service_Create
    'the parameters may discovered with Log(intent.extrasToString) in the OnReceive Method
    BC.Initialize("BC")

End Sub

Sub Service_Start (StartingIntent As Intent)
    'category and action must match the settings in datawedge app
    BC.addCategory("intent_kategorie")
    BC.addAction("scanner_intent")
    BC.SetPriority(20000000)
    RegisterReceiver("scanner_intent")
    Service.StopAutomaticForeground 'Call this when the background task completes (if there is one)
End Sub

Sub Service_Destroy

End Sub

Sub BC_OnReceive (action As String, o As Object)
    Dim intent As Intent = o
    Log("Service : " & intent.Action)

    Dim code As String
    If intent.HasExtra("com.symbol.datawedge.data_string") Then
        code = intent.GetExtra("com.symbol.datawedge.data_string")
    Else If intent.HasExtra("com.motorolasolutions.emdk.datawedge.data_string") Then
        code = intent.GetExtra("com.motorolasolutions.emdk.datawedge.data_string")
    Else
        Return
    End If
    CallSubDelayed2(Main,"process_barcode", code)
End Sub

Private Sub RegisterReceiver(action As String)
    BC.registerReceiver(action)
End Sub

Receiver Module:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
End Sub

'Called when an intent is received.
'Do not assume that anything else, including the starter service, has run before this method.
Private Sub Receiver_Receive (FirstTime As Boolean, StartingIntent As Intent)
    Log("Receiver : " & StartingIntent.Action)

    Dim code As String
    If StartingIntent.HasExtra("com.symbol.datawedge.data_string") Then
        code = StartingIntent.GetExtra("com.symbol.datawedge.data_string")
    Else If StartingIntent.HasExtra("com.motorolasolutions.emdk.datawedge.data_string") Then
        code = StartingIntent.GetExtra("com.motorolasolutions.emdk.datawedge.data_string")
    Else
        Return
    End If
    CallSubDelayed2(Main,"process_barcode", code)
End Sub
Manifest:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="35"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.LightTheme)
'End of default text.
AddReceiverText(zebrareceiver,
<intent-filter>
    <category android:name="intent_kategorie" />
    <action android:name="scanner_intent" />
</intent-filter>)
SetReceiverAttribute(zebrareceiver, android:exported, "true")

Have you checked the device documentation? Maybe it only works with dynamic intent filters.

I can't see anything in the device documentation about dynamic intent filters. There is information about configuring intent filters your apps manifest, which I think is the "non-dynamic" method, so can't imagine it's this causing the issue.
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
it looks like you have your receiver both dynamically and contextually declared at the same time.
 
Upvote 0
Top