Android Question Send File to Mobile using qrcode

Alain Maes

Member
Licensed User
Longtime User
Hello Everybody,
Has someone experience with sending a file (for example a csv) from pc to mobile app using a qrcode ?

Already Thanks
Alain
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
The maximum length of a single code in byte mode is less than 3kb: https://www.thonky.com/qr-code-tutorial/character-capacities

If you want to transfer a file with QR Code then you will need to split the file and build it back on the Android.

Worth checking the compressed size. Maybe it is small enough.
 
Upvote 0

Alain Maes

Member
Licensed User
Longtime User
Hello,
In fact here is the full story.
I have a web site with a datatable and i want that when i click on a button that the datatable content is sent via wifi to my mobile app when i scan a qr code (as the QRCODE cannot contain a 20 kb csv file)
Of course my mobile is on the same wifi has the pc
I don't know how to do this

Kind Regards
 
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
i think your trigger is scanning the qr code first.
you can find here in forum example for extern reader apps (via ABZing lib) or build in barcode scanner librarys.

then u make a get request (url with id) with okhttputils2 library.
u can catch that request via php if u have a web server and return the file, or making a non ui java server app with jServer library in b4j.

B4X:
  Dim Job As HttpJob
   Job.Initialize("Job1",Me)
   Job.Username="abc"
   Job.Password="123"
   Job.Download("https://api.yourdomain.com/api?getfile=" & ID)


see also wait for example ..
B4X:
Sub JobDone (Job As HttpJob)
 
    Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
    If Job.Success = True Then
        Select Job.JobName
            Case "Job1"

                Log(Job.GetString)        '<- answer from web server
        End Select
    Else
        Log("Error: " & Job.ErrorMessage)
        ToastMessageShow("Error: " & Job.ErrorMessage, True)
    End If
    Job.Release
 
End Sub

usage ABZing lib (+ a Public Scan App from Google Store) in an Activity
B4X:
#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.

    'https://www.b4x.com/android/forum/threads/abzxing-barcode-reader.7303/#content
    Private myABBarcode As ABZxing 'muss man erst kaufen dann kann man ein Zip runter laden, die Lib nutzt die App aus dem Play Store ..

    Private ButtonScan As Button
    Private EditTextBC As EditText
    Private LabelFormat As Label
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("Scan")

    EditTextBC.Text="..."
    LabelFormat.Text = "..."
  
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub ButtonScan_Click
  
    EditTextBC.Text = "..."
    LabelFormat.Text = "..."
    myABBarcode.ABGetBarcode("myABBarcode", "")
      
End Sub

Sub myABBarcode_BarcodeFound(barCode As String, formatName As String)

    Main.ScannedBarcode = barCode
  
    EditTextBC.Text = barCode
    LabelFormat.Text = formatName

End Sub

Sub myABBarcode_Canceled

    Main.ScannedBarcode = ""

    EditTextBC.Text = "Canceled"
    EditTextBC.Enabled=True
    LabelFormat.Text = ""

End Sub

Sub EditTextBC_EnterPressed

    Main.ScannedBarcode = EditTextBC.Text.Trim 
    LabelFormat.Text = "OK"
  
End Sub
 
Last edited:
Upvote 0

Alain Maes

Member
Licensed User
Longtime User
Hello,
This suppose that the file is hosted on the website somewhere, the project is to be able to do this without saving the file to the internet first.

Other solution for me to transfer a file is with usb key

Thks for your reaction

Kind Regards

Alain
 
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
Upvote 0
Top