I've been using the following code to download one file from web server. The value of FileUrl is set with the appropriate file I am downloading. Is possible to send a list of files to download, or is necessary to do them individually, by changing the value of FileUrl for each file.
B4X:
Sub get_new_data
HttpUtils.CallbackActivity = "Main" 'Current activity name.
HttpUtils.CallbackJobDoneSub = "JobDone"
HttpUtils.Download("Job1", FileUrl)
End Sub
Sub JobDone (Job As String)
If HttpUtils.IsSuccess(FileUrl) Then
File.Copy2(HttpUtils.GetInputStream(FileUrl),File.OpenOutput(File.DirDefaultExternal,"filename",False))
End If
End Sub
:sign0085::sign0085:
hi,
i'm trying to download a text file from a website using the above sample
the result is an empty file
what i get is the file in the right place but no content - it is empty
i'm using this exact sample, just changed the file name and url, naturally
alternatively - can any one help with a good & simple example on how to directly download a text file from a url ?
this is really urgent for me and i do appreciate any help
Sub Activity_KeyPress (KeyCode As Int) As Boolean ' Return true to consume the event
If KeyCode = KeyCodes.KEYCODE_BACK Then ' Back button
'your code here
Return True ' Consume event, so the app does not close
Else
Return False ' Do not consume, the app will close or go to previous activity
End If
End Sub
For error catching (from the B4A HelpViewer which is indispensable)
B4X:
Exception
Holds a thrown exception.
You can access the last thrown exception by calling LastException.
For example:
Try
Dim in As InputStream
in = File.OpenInput(File.DirInternal, "SomeMissingFile.txt")
'...
Catch
Log(LastException.Message)
End Try
If in.IsInitialized Then in.Close
anyone has any info on how to use a printer ?
i mean - i have a samsung bixolon spp-200 - it's a thermal printer with bluetooth card reader.
anyone has any experience with such a nut ?