Android Question GET DATA FROM INTENT EVENT (Barcode data from Device)

Gianni Sassanelli

Active Member
Licensed User
Longtime User
Hi i need to get readed barcode from some device that have hardware laser scanner into.

Now i get data from EditText setting hardware with Keyboard emulator

But i need to get more data as example Barcode Type and some barcode Fields with 2d Barcode.

the device that i'm using have INTENT DATA READ MODE but i don't know hot to intercept this event.

Can someone help me to do this Please

i attach the configuration screen-shots and some test but unsuccessfully

thanks


Manifest setting:
B4X:
AddReceiverText(service1,
<intent-filter>
    <action android:name="android.intent.action.BARCODE_BR_DECODING_DATA" />
</intent-filter>)

Service Module:
B4X:
#Region  Service Attributes 
    #StartAtBoot: true
    
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
 'Type Message (Address As String, Body As String)
End Sub

Sub Service_Create

End Sub

Sub Service_Start (StartingIntent As Intent)
    Log(StartingIntent.Action)
    Service.StopAutomaticForeground 'Call this when the background task completes (if there is one)
End Sub

Sub Service_Destroy

End Sub

Main Module
B4X:
#Region  Project Attributes 
    #ApplicationLabel: Test
    #VersionCode: 1
    #VersionName: 1.1
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
    #LibraryVersion: 1.2
#End Region

#Region  Activity Attributes 
    #FullScreen: False
    #IncludeTitle: True
#End Region

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 barcode As EditText
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    Activity.LoadLayout("1.bal")
    StartService(service1)
End Sub

Sub Activity_Resume
    'Dim iIn As Intent
    'iIn = Activity.GetStartingIntent
    
'    Dim str As String 
'    str = iIn.ExtrasToString
'    Log(str)
'    str = Activity.GetStartingIntent.ExtrasToString
'    Log(str)
    'Log(Activity.GetStartingIntent.HasExtra("android.intent.extra.EXTRA_BARCODE_DECODED_DATA"))
    'Log(Activity.GetStartingIntent.GetExtra("android.intent.extra.EXTRA_BARCODE_DECODED_DATA"))
'Dim in As JavaObject = Activity.GetStartingIntent
'Log(in.RunMethod("getParcelableExtra", Array("android.intent.extra.STREAM")))


'All methods returns NULL or FALSE
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub




Sub barcode_TextChanged (Old As String, New As String)
'    Dim iIn As Intent
'    iIn = Activity.GetStartingIntent
'    Dim str As String 
'    
'    str = iIn.ExtrasToString
'    Log(str)
End Sub
 

Attachments

  • WhatsApp Image 2020-09-07 at 13.48.31.jpeg
    WhatsApp Image 2020-09-07 at 13.48.31.jpeg
    129.5 KB · Views: 214
  • WhatsApp Image 2020-09-07 at 13.48.50.jpeg
    WhatsApp Image 2020-09-07 at 13.48.50.jpeg
    117.3 KB · Views: 209
Top