Android Question Some newbye questions about download files from web and contact a page

corvo

Member
Licensed User
Longtime User
Hi, i have 2 questions:

1) need to download 2 file from a web site, i tried as lot of code but whitout succes, please someone can paste a simple code for download 2 files? (not in asyncronos mode)
2) i need to contact a web page for make querystring, (www.mypage.php?domanda=yes) how i can do it?

Thankyou guys!
 

DonManfred

Expert
Licensed User
Longtime User
this don't works in my project.....
Export and zip your project and upload it here.
I´m sure httputils will work in your project too.

But NOTE: httputils does NOT do a sync download.

A Download will always happen asynchronous.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
For the lazy ones under us

B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    Dim job As HttpJob
    job.Tag = "file.txt"
  job.Initialize("file1", Me)
  job.Download("http://www.mysite.com/file.txt")
    Dim job As HttpJob
    job.Tag = "file2.txt"
  job.Initialize("file2", Me)
  job.Download("http://www.mysite.com/file2.txt")
End Sub
Sub JobDone(Job As HttpJob)
    ProgressDialogHide
  If Job.Success Then
        If Job.JobName = "file1" Then
            Dim out As OutputStream
            out = File.OpenOutput(File.DirRootExternal,Job.Tag,False )
            File.Copy2(Job.GetInputStream, out)
            out.Close
        End If
        If Job.JobName = "file2" Then
            Dim out As OutputStream
            out = File.OpenOutput(File.DirRootExternal,Job.Tag,False )
            File.Copy2(Job.GetInputStream, out)
            out.Close
        End If
  Else
      Log( Job.ErrorMessage)
  End If
    Job.Release
End Sub

PS: I guess i will regret doing this for a user who is longer member here in forum than me
 

Attachments

  • twofiles.zip
    7 KB · Views: 115
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
every time it will be asked
you are surely right... But for this i need to search for the solution by myself :D

For now it was easier to have a look at my test-projects-folder and to edit one of my examples to post it here
 
Upvote 0

corvo

Member
Licensed User
Longtime User
thankyou so much guys, but i'm not lazy, i'm just very very rusty, i used this software 2 years ago for a project, i don't remember nothing :( another little help, how i can contact the webpage for pass the string? i will post my (maybe i must say our) project when it will be ready :p
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
For every new question you should start A NEW thread.

Please note that httputils2 is the right candidate for this too.

- See my signature for examples.
- Search the forum for example. There are plenty of it
- Go over the httputils2 tutorial and learn how to work with httputils2. You´ll soon reach the point to recognize that you are on the right way
 
Last edited:
Upvote 0
Top