Android Question laser bar code intent

werner_Fourie

Member
Licensed User
Longtime User
Hi all..

I'm stuck with this..

I need to get the bar code from the internal bar code reader with this intent..

Broadcast name is > com.scanner.broadcast
key > data

I have never worked with intents and I just need a little help please..

Thanking You in advance..
 

werner_Fourie

Member
Licensed User
Longtime User
I'm getting nothing on the B4A log and nothing on the device. I have set the app to "Scan Vehicle Data"
Is Your scanner setup for "intent mode"
Go to the scanner settings and check for that..
If there is nothing in the log then the configuration is wrong..
I know the code works..
 
Upvote 0

Setlodi

Member
Hi Werner
Thank you for your continued support.
Herewith are screenshots of my scanner setting from the Sunmi Partner Portal:

1668585664296.png

I've tried different settings but nothing:

1668585774478.png
1668585774478.png1668585664296.png
 
Upvote 0

werner_Fourie

Member
Licensed User
Longtime User
make sure this is in the manifest..

AddReceiverText(Service1,
<intent-filter >
<action android:name="com.scanner.broadcast" />
</intent-filter>
)

change everything back to where my code was..


.......change on the scanner......
change the broadcast name to com.scanner.broadcast
change raw byte value to dataBytes
don't alter the key value

Scan and check the logs for something.. It will look like garbage..
Send me the logs
 
Upvote 0

Setlodi

Member
Hi Werner

I did exactly as you suggested and I'm still not getting anything. I compiled your code as is and made the changes on the device and on the manifest as well. I did not change a single thing in your code. I have attached some screenshots...

Here are the logs after successfully compiling:

Logs
Starter - 425: Unused variable 'New_Battery_Value_For_Device_1'. (warning #9)
Starter - 442: Unused variable 'New_Battery_Value_For_Device_2'. (warning #9)
Starter - 459: Unused variable 'New_Battery_Value_For_Device_3'. (warning #9)
Main - 96: Sub 'GetRealSize' is not used. (warning #12)
B4XMainPage - 592: Variable 'Panel_Network' was not initialized. (warning #11)
Starter - 181: Sub 'GetBroadcastAddress' is not used. (warning #12)
The recommended value for android:targetSdkVersion is 30 (manifest editor). (warning #31)

==================================================================
Logger connected to: SUNMI L2s
--------- beginning of main
--------- beginning of system
Copying updated assets files (73)
*** Service (starter) Create ***
Starter Service Created
** Service (starter) Start **
Starter Service Started
** Activity (main) Create, isFirst = true **
Is_ACCELEROMETER_Supported true
Is_GYROSCOPE_Supported true
Is_LIGHT_Supported true
Is_PROXIMITY_Supported true
*** mainpage: B4XPage_Created
Program Starting.....
----------------------------------------------
Animation To Use >Bounce
Load Gyro In Store
Enable Gyro Roll false
Enable Gyro Pitch false
User Zero Gyro Roll 0
User Zero Gyro Pitch 0
----------------------------------------------
Load_UDP_In_Store
UDP 1 Port_No Port?
UDP 2 Port_No Port?
UDP 3 Port_No Port?
UDP 4 Port_No Port?
UDP 5 Port_No Port?
This Device ID Please Set Device ID
This WiFi Name Please Set WiFi Name
This IP Address Please Select a Network for IP Address
This Broadcast IP_Address Please Set Broadcast Address
Remote IP Address 1 Please Set IP Address 1
Remote IP Address 2 Please Set IP Address 2
Remote IP Address 3 Please Set IP Address 3
Remote IP Address 4 Please Set IP Address 4
Remote IP Address 5 Please Set IP Address 5
Enable UDP Device 1 false
Enable UDP Device 2 false
Enable UDP Device 3 false
Enable UDP Device 4 false
Enable UDP Device 5 false
----------------------------------------------
Load Last Printed Vehicle In Store
Last Printed Vehicle No Data For Last Printed Vehicle
----------------------------------------------
Load Bluetooth Device 1 In Store
Device Name Scale 1 Please Choose a Device
Mac Scale 1 00:00:00:00:00:00:00
Device Enabled Scale 1 false
Cal Enabled Scale 1 false
Remove Text Scale 1 false
----------------------------------------------
Load Bluetooth Device 2 In Store
Device Name Scale 2 Please Choose a Device
Mac Scale 2 00:00:00:00:00:00:00
Device Enabled Scale 2 false
Cal Enabled Scale 2 false
Remove Text Scale 2 false
----------------------------------------------
Load Bluetooth Device 3 In Store
Device Name Scale 3 Please Choose a Device
Mac Scale 3 00:00:00:00:00:00:00
Device Enabled Scale 3 false
Cal Enabled Scale 3 false
Remove Text Scale 3 false
----------------------------------------------
Load Bluetooth Device 4 In Store
Device Name Scale 4 Please Choose a Device
Mac Scale 4 00:00:00:00:00:00:00
Device Enabled Scale 4 false
----------------------------------------------
Load Scale 1 In Store
Scale 1 Division Size 1
Scale 1 Calibration Mass 1000
Scale 1 Zero Counts 0
Scale 1 Span Factor 133.0
Scale 1 Decimal Point 0
Scale 1 Resolution 3000
Scale 1 Unit kg
Scale 1 User Selected Max Capacity 3000
Scale 1 Tare Mass 0
Scale 1 Lo Setpoint 0
Scale 1 Hi Setpoint 0
Scale 1 Slider Maximum 3000
----------------------------------------------
Load Scale 2 In Store
Scale 2 Division Size 1
Scale 2 Calibration Mass 1000
Scale 2 Zero Counts 0
Scale 2 Span Factor 133.0
Scale 2 Decimal Point 0
Scale 2 Resolution 3000
Scale 2 Unit kg
Scale 2 User Selected Max Capacity 3000
Scale 2 Tare Mass 0
Scale 2 Lo Setpoint 0
Scale 2 Hi Setpoint 0
Scale 2 Slider Maximum 3000
----------------------------------------------
Load Scale 3 In Store
Scale 3 Division Size 1
Scale 3 Calibration Mass 1000
Scale 3 Zero Counts 0
Scale 3 Span Factor 133.0
Scale 3 Decimal Point 0
Scale 3 Resolution 3000
Scale 3 Unit kg
Scale 3 User Selected Max Capacity 3000
Scale 3 Tare Mass 0
Scale 3 Lo Setpoint 0
Scale 3 Hi Setpoint 0
Scale 3 Slider Maximum 3000
----------------------------------------------
Screen Brightness > 0.05
Screen Brightness > 0.05
Screen Brightness > 0.05
Screen Brightness > 0.05
Screen Sound > 0.05
Screen Sound > 0.05
Screen Sound > 0.05
Screen Sound > 0.05
Label Hi Go Lo_Scale High Value 1 0
Label Hi Go Lo_Scale Low Value 1 0
----------------------------------------------
Label Hi Go Lo_Scale High Value 1 0
Label Hi Go Lo_Scale Low Value 1 0
----------------------------------------------
Label Hi Go Lo_Scale High Value 1 0
Label Hi Go Lo_Scale Low Value 1 0
----------------------------------------------
Label Hi Go Lo_Scale High Value 1 50
Label Hi Go Lo_Scale Low Value 1 0
----------------------------------------------
Label Hi Go Lo_Scale High Value 2 0
Label Hi Go Lo_Scale Low Value 2 0
----------------------------------------------
Label Hi Go Lo_Scale High Value 2 0
Label Hi Go Lo_Scale Low Value 2 0
----------------------------------------------
Label Hi Go Lo_Scale High Value 2 0
Label Hi Go Lo_Scale Low Value 2 0
----------------------------------------------
Label Hi Go Lo_Scale High Value 2 50
Label Hi Go Lo_Scale Low Value 2 0
----------------------------------------------
Label Hi Go Lo_Scale High Value 3 0
Label Hi Go Lo_Scale Low Value 3 0
----------------------------------------------
Label Hi Go Lo_Scale High Value 3 0
Label Hi Go Lo_Scale Low Value 3 0
----------------------------------------------
Label Hi Go Lo_Scale High Value 3 0
Label Hi Go Lo_Scale Low Value 3 0
----------------------------------------------
Label Hi Go Lo_Scale High Value 3 50
Label Hi Go Lo_Scale Low Value 3 0
----------------------------------------------
Load Bluetooth Device 1 In Store
Device Name Scale 1 Please Choose a Device
Mac Scale 1 00:00:00:00:00:00:00
Device Enabled Scale 1 false
Cal Enabled Scale 1 false
Remove Text Scale 1 false
----------------------------------------------
Load Bluetooth Device 2 In Store
Device Name Scale 2 Please Choose a Device
Mac Scale 2 00:00:00:00:00:00:00
Device Enabled Scale 2 false
Cal Enabled Scale 2 false
Remove Text Scale 2 false
----------------------------------------------
Load Bluetooth Device 3 In Store
Device Name Scale 3 Please Choose a Device
Mac Scale 3 00:00:00:00:00:00:00
Device Enabled Scale 3 false
Cal Enabled Scale 3 false
Remove Text Scale 3 false
----------------------------------------------
Load Bluetooth Device 4 In Store
Device Name Scale 4 Please Choose a Device
Mac Scale 4 00:00:00:00:00:00:00
Device Enabled Scale 4 false
----------------------------------------------
Load Bluetooth Hardware In Store false
----------------------------------------------
160.0
160.0
4.5
9
----------------------------------------------
Check_What_Scale_Panels_Must_Be_Loaded
----------------------------------------------
Bluetooth Device List Loaded
----------------------------------------------
Bluetooth Device 1 Does Not Need To Run
----------------------------------------------
Check_What_Scale_Panels_Must_Be_Loaded
----------------------------------------------
Bluetooth Device List Loaded
----------------------------------------------
Bluetooth Device 2 Does Not Need To Run
----------------------------------------------
Check_What_Scale_Panels_Must_Be_Loaded
----------------------------------------------
Bluetooth Device List Loaded
----------------------------------------------
Bluetooth Device 3 Does Not Need To Run
----------------------------------------------
Check_What_Scale_Panels_Must_Be_Loaded
----------------------------------------------
Bluetooth Device List Loaded
----------------------------------------------
Bluetooth Device 4 Does Not Need To Run
----------------------------------------------
Load Scale 1 Tare Mass
----------------------------------------------
Load Scale 2 Tare Mass
----------------------------------------------
Load Scale 3 Tare Mass
----------------------------------------------
Screen Brightness To Use > 1
Screen Brightness > 1
Screen Brightness > 1
Screen Sound To Use > 1
Screen Sound > 1
Screen Sound > 1
160.0
160.0
----------------------------------------------
Close_UDP_1_Sockets
Close_UDP_2_Sockets
Close_UDP_3_Sockets
Close_UDP_4_Sockets
Close_UDP_5_Sockets
Program Starting Done
----------------------------------------------
Hold WiFi On State >true
*** mainpage: B4XPage_Appear
Hide Scroller
Item cannot be highlighted
** Activity (main) Resume **
Activity_Resume
----------------------------------------------
PROXIMITY_SensorChanged 1
PROXIMITY_SensorChanged 1
** Activity (main) Pause event (activity is not paused). **
Screen Brightness 1
Sound Volume 1
Hide Scroller
*** mainpage: B4XPage_Disappear [mainpage]
Activity_Pause User Closed false
----------------------------------------------
sending message to waiting queue (OnActivityResult)
*** mainpage: B4XPage_PermissionResult [mainpage]
Activity_PermissionResult
----------------------------------------------
*** mainpage: B4XPage_PermissionResult [mainpage]
Activity_PermissionResult
----------------------------------------------
running waiting messages (1)
** Activity (main) Resume **
*** mainpage: B4XPage_Appear [mainpage]
Activity_Resume
----------------------------------------------
PROXIMITY_SensorChanged 1
 

Attachments

  • Screenshot_20221116-202458.png
    Screenshot_20221116-202458.png
    79.7 KB · Views: 108
  • Screenshot_20221116-175408.png
    Screenshot_20221116-175408.png
    113.8 KB · Views: 103
Upvote 0

werner_Fourie

Member
Licensed User
Longtime User
Hi


If B4XPages.MainPage.Barcode_Scann_Mode.Text = "Scan Driver Data" Then
Intent_StrBuff_LIC = StartingIntent.GetExtra("dataBytes")
Log(Intent_StrBuff_LIC) *******Put Log() here...*******


This happens when You Scan a License..
From what country is the licence You are scanning...?


----------------------------------------------
** Receiver (service1) OnReceive ********* This needs to trigger
** Service (service1) Start **
Service_Start
[B@4f79e86 ************ You need to get some information like this line....

if not Your scanner is not setup correctly


This is the result from the scan after going through the decoder..

result.length = 128
result[0] = 1
amendedSection2 = 0220020425........................00........0119830524201811222023112101
ID Type 02
Issue Date 1 20020425
Issue Date 2 ........
Issue Date 3 ........
Issue Date 4 ........
Driver Restrictions 00
Expiry Date ........
License Issue Number 01
Birth Date 19830524
Gender Female
Valid To 20231121
01
Surname: LIEBENBERG Initials: WJ ID Number: 8305245183087 License Number: 412200073KP6 Valid To 20231121

I have send You a video of the software working..
 
Upvote 0

Setlodi

Member
Hi Werner. Nothing is happening, nothing in the log. Like you said, it looks like my scanner is not setup correctly. I think it has do to with the AIDL thingy. I have an AIDL file that I have downloaded with the code from the scanner manufacturer. I'm still trying to figure it out.
 
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
There is a field in your setup that says "Fill EditText directly". Try and set it, add just one EditText to your activity and see if the EditText is filled with the scan result when you do a scan.
 
Upvote 0

Setlodi

Member
Hi Johan
Thank you for your input. I have added a text box to Werner's Scanner application. As you can see in the screenshot, it does scan and input the unencrypted scan result in the EditText box. This is from my drivers license. But as you might be aware, this is only on the "surface".
 

Attachments

  • Screenshot_20221120-155310.png
    Screenshot_20221120-155310.png
    155.9 KB · Views: 104
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
Have you tried in the service code to do this in place of what you have
B4X:
Dim content() As Byte = StartingIntent.GetExtra("dataBytes")
strBuff = con.StringFromBytes(content,"ISO8859_1")
Log(strBuff)

Dim content() As Byte = StartingIntent.GetExtra("dataBytes")
 
Upvote 0

Setlodi

Member
Hi Johan and Werner

I think the Service1 module does not start at all. I've tried everything you suggested but I'm still not getting anything. Now I also added a Log in B4XMainPage to see if something will show and, alas! I could see the logs. Below are the logs that I added:

Testing the Log:
Private Sub CheckBox_Select_Scan_Mode_ValueChanged (Value As Boolean)
    If CheckBox_Select_Scan_Mode.Value = True Then
        service1.Barcode_Mode_Seletion = "Vehicle"
        Barcode_Scann_Mode.Text = "Scan Vehicle Data"
      
        'Test log
        Log("XXXXXXXXXXXX Vehicle " & Barcode_Scann_Mode.Text)
      
    Else 
        service1.Barcode_Mode_Seletion = "Driver"
        Barcode_Scann_Mode.Text = "Scan Driver Data"
      
        'Test log
        Log("XXXXXXXXXXXX Driver " & Barcode_Scann_Mode.Text )
      
    End If
  
End Sub

From this I was able to see the following in the log, as I toggle between Driver and Vehicle selection on my hand held device:


running waiting messages (1)
** Activity (main) Resume **
*** mainpage: B4XPage_Appear [mainpage]
Activity_Resume
----------------------------------------------
PROXIMITY_SensorChanged 1
XXXXXXXXXXXX Vehicle Scan Vehicle Data
XXXXXXXXXXXX Driver Scan Driver Data
XXXXXXXXXXXX Vehicle Scan Vehicle Data
XXXXXXXXXXXX Driver Scan Driver Data
XXXXXXXXXXXX Vehicle Scan Vehicle Data
XXXXXXXXXXXX Driver Scan Driver Data
XXXXXXXXXXXX Vehicle Scan Vehicle Data
XXXXXXXXXXXX Driver Scan Driver Data
XXXXXXXXXXXX Vehicle Scan Vehicle Data
XXXXXXXXXXXX Driver Scan Driver Data

Somehow, the scanner can communicate with the app because I'm using it to toggle between "Scan Vehicle Data" and "Scan Driver Data".

What triggers the Service1 module to start?

Region Service Attribute of Service1:
#StartAtBoot: True
 
Upvote 0

werner_Fourie

Member
Licensed User
Longtime User
I understood from post #29 above that you do get a scan result ( string) when you do a scan. Is that correct?
Hi..

Look at the video that i emailed You ..It is working..It is not seeing Your scanner or the scanner is configured wrong..
This part should trigger

This is for when Your scanner is in intent mode..

** Receiver (service1) OnReceive ********* This needs to trigger
** Service (service1) Start **
Service_Start
[B@4f79e86 ************ You need to get some information like this line....

if not Your scanner is not setup correctly..
 
Upvote 0

Setlodi

Member
I understood from post #29 above that you do get a scan result ( string) when you do a scan. Is that correct?
Ok, this is what I've done to check if my scanner works. I went into the DESIGNER and created a EDITTEXT box in Form_1Panel_3. I enlarged the box to fit the screen. After compiling the app, I clicked on the text box on the screen and scanned the driver's license. The unencrypted scan results are displayed in the text box. This is how I was able to get the scan result.
 

Attachments

  • Design_Screenshot.jpg
    Design_Screenshot.jpg
    212.5 KB · Views: 103
Upvote 0

Setlodi

Member
I didn't do anything to the code. Werner confirmed through a video he shared in his previous post that the system works. This is the original source code from him. All I did was add the text box in design and the logs.
 
Upvote 0

werner_Fourie

Member
Licensed User
Longtime User
I didn't do anything to the code. Werner confirmed through a video he shared in his previous post that the system works. This is the original source code from him. All I did was add the text box in design and the logs.
If Your scanner sends a string to a text box then it is not in "intent" mode as my app requires..

Your scan result was where the scanner is in text mode..The scrambled text You see is normal..It needs to be decoded.

That only proves that the scanner itself is working.. It now needs to be decoded from that text box as it is decoded from the intent part..

When You put Your scanner in intent mode, if that is the way You want it to work You must make sure that the scanner is setup correctly for the intent to be received in the app..

My app works with intents..

If You want to use it as a text scanner to text box in my app You are going to have to do much more figuring out what to do..

Hope that helps..

If You live in Gauteng I could assist You over the weekend if You bring all your gear to my place..
 
Last edited:
Upvote 0

Setlodi

Member
If Your scanner sends a string to a text box then it is not in "intent" mode as my app requires..

The way You scanned it is correct if it was to a text box and the scanner is in text mode..

That only proves that the scanner itself is working.. It now needs to be decoded from that text box as it is decoded from the intent part..

When You put Your scanner in intent mode, if that is the way You want it to work You must make sure that the scanner is setup correctly for the intent to be received in the app..

My app works with intents..

If You want to use it as a text scanner to text box in my app You are going to have to do much more figuring out what to do..

Hope that helps..
Thanks, this helps a lot Werner. I have been going through the settings in the actual scanning device and there's nothing about setting up the Intents. I have sent a message to the manufacturer and they should get back to me in a day or so. I do not want it as a text scanner as this will just confuse things. I will find a way of setting up the intents mode in the scanner and work with your app as it was intended. I will keep you guys informed of my progress. Much appreciation for your continued support.
 
Upvote 0

Setlodi

Member
If Your scanner sends a string to a text box then it is not in "intent" mode as my app requires..

Your scan result was where the scanner is in text mode..The scrambled text You see is normal..It needs to be decoded.

That only proves that the scanner itself is working.. It now needs to be decoded from that text box as it is decoded from the intent part..

When You put Your scanner in intent mode, if that is the way You want it to work You must make sure that the scanner is setup correctly for the intent to be received in the app..

My app works with intents..

If You want to use it as a text scanner to text box in my app You are going to have to do much more figuring out what to do..

Hope that helps..

If You live in Gauteng I could assist You over the weekend if You bring all your gear to my place..
Hi Werner. Yes, I live in Gauteng. We are available on Saturday 14h00 - 18h00 and on Sunday 09h00 - 12h00. If this doesn't suit you, please suggest an alternative time and we will work around it.

Thanks
 
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
Keep POPI act in mind. You cannot collect personal info without concent. Wherever I go and at entry they want to scan my car license and/or driver licence I throw POPI at them and have never been refused entry without scanning as they are all very aware of POPI act.
 
Last edited:
Upvote 0
Top