Android Tutorial ImageDownloader - The simple way to download images

Discussion in 'Tutorials & Examples' started by Erel, Jul 9, 2013.

Thread Status:
Not open for further replies.
  1. omidaghakhani1368

    omidaghakhani1368 Well-Known Member Licensed User

    ِYou have a like :)
     
  2. Bryanne Vega

    Bryanne Vega Member Licensed User

  3. DonManfred

    DonManfred Expert Licensed User

    Yes. Create a new thread for your issue and give us MUCH MORE information than just this damned erromessage
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    You probably forgot to add http:// to the link.
     
  5. Ratna Fang

    Ratna Fang Member Licensed User

    i'm sorry perhaps i missed something
    for variable MAX_CACHE_SIZE, is there any part to declare the variable?
    dim MAX_CACHE_SIZE as int or dim MAX_CACHE_SIZE as long?

    or MAX_CACHE_SIZE is a system variable which is determined by each handheld?
     
  6. Blue.Sky

    Blue.Sky Active Member Licensed User

    Hi
    I have a 200 picture that load with imagedownloader
    But when i start it,my app show isn't responding
    what is problem?
     
  7. Douglas Farias

    Douglas Farias Expert Licensed User

    200 Imagens is too much for one app.
    what the sizes of the imagens?
     
  8. Blue.Sky

    Blue.Sky Active Member Licensed User

    I think 200 * 20kb
    But i should use 200 image
     
  9. DonManfred

    DonManfred Expert Licensed User

    No one see 200 images at once on the screen. You should consider a pagination if there are much images. Show 10 Images and but a button for ex. which then loads 10 more images. Or something similar.

    Additional the FILESIZES does not matter. The Image-DIMENSIONS (Width * Height) DOES

    What dimensions does the images have (witdh/height)?
     
  10. Blue.Sky

    Blue.Sky Active Member Licensed User

    Different size.Please visit AppYet website,This website download rss and image synchronize and not problem(no pagination)
     
  11. Mashiane

    Mashiane Expert Licensed User

    Is it possible to have the ImageDownloader to reflect the percentage progress of the downloaded image or current file size / total file size variable? I want to show a placeholder image in place showing loading progress until the image is fully loaded. Anyone?
     
  12. Declan

    Declan Active Member Licensed User

    How can I adapt the code in ImageDownloader2 to load an image and text from a remote MySQL database?
    I am successfully downloading and displaying the image (BLOB) in an ImageView and the text in a Label with this code in my JobDone sub:
    Code:
    If result.Tag = "select_img" Then
                        
    For Each records() As Object In result.Rows
                            
    Dim Buffer() As Byte
                            
    Dim HeaderTxt As String
                            Buffer = records(result.Columns.Get(
    "img02"))
                            HeaderTxt = records(result.Columns.Get(
    "TxtHeader"))
                            
    Dim InputStream1 As InputStream
                            InputStream1.InitializeFromBytesArray(Buffer, 
    0, Buffer.Length)
                            
    Dim Bitmap1 As Bitmap
                            Bitmap1.Initialize2(InputStream1)
                            InputStream1.Close
                            ImageView1.SetBackgroundImage(Bitmap1)
                            Label1.Text = HeaderTxt
                        
    Next
                    
    End If
    I need to incorporate the above code into the following original code of the ImageDownloader2 JobDone sub:
    Code:
    If Job.Success = True Then
            
    If Job.JobName = "PageJob" Then
                
    Dim m As Matcher = Regex.Matcher("class=\""darkbox\""><img src=\""([^""]+)""", Job.GetString)
                
    Do While m.Find
                    links.Add(m.Group(
    1))
                
    Loop
                BuildItems
            
    End If
        
    Else
            
    Log(Job.ErrorMessage)
        
    End If
     
  13. Erel

    Erel Administrator Staff Member Licensed User

    Please start a new thread for this question.
     
  14. Jorgelcr

    Jorgelcr Member Licensed User

    Hello,

    I had already seen this code, my problem is that I try to download the image inside another loop that is shown the registers. I explain:

    I have a table-> Companies with three fields (Name, Location, Logo) In the field I soon save the ftp path of the file I uploaded.

    I create a loop to browse the companies and show in a listview their Name and Location. I look if the field logo is empty and in case it is not empty I want to download the image and display it. So easy and so complicated.


    Code:
    Sub Activity_Create(FirstTime As Boolean)
     
        
    Activity.LoadLayout("logos")

     
        ExecuteRemoteQuery(
    "Select * From Empresas " , "EMPRESAS")
     
      
    End Sub
    Sub ExecuteRemoteQuery(Query As String, JobName As String)
        job1.Initialize(
    "Job1", Me)
        job1.PostString(
    "http://www.miweb.com/empresas.php", Query)
        
    End Sub
    Sub JobDone(job As HttpJob)

    Select job.JobName
            
    Case "Job1"
                
    If job.Success Then
                    
    Dim res As String
                    res = job.GetString
                    
    Log("Response from server: " & res)
                    
    Dim parser As JSONParser
                    parser.Initialize(res)
                    COUNTRIES = parser.NextArray 
    'returns a list with maps
                    For i = 0 To COUNTRIES.Size - 1 'bucle para recorrer los registros de la tabla
                        m = COUNTRIES.Get(i)
                        
    If m.Get("logo")=Null Then 'comprobar si tiene logo
                            ListView1.AddTwoLines(m.Get("Nombre"),m.Get("Localidad"))
                        
    Else
                           
    'Descargar logo
                            imageurl2 = "http://www.miweb.com/logo/" & m.Get("logo")
                            json.Initialize(job.GetString)
                            job2.Initialize(
    "Image",Me)
                            job2.Download(imageurl2)
                     
                    
                        
    End If
                    
    Next
                
    End If
            
    Case "Image"
               
    'Mostrar logo en Listview ListView1.AddTwoLinesAndBitmap(m.Get("Nombre"),m.Get("Localidad"),job2.GetBitmap)
    End Select
    End Sub
     
  15. DonManfred

    DonManfred Expert Licensed User

    Please start a new thread in the questions forum for this.
    Your concept does have multiple problems. One of it is that you are using a Listview where you should use a CustomListView (using Imageviews for the logos)

    Create a new thread, create a small project (including your DB) showing your problem and upload it.
     
    MarcoRome likes this.
  16. desof

    desof Well-Known Member Licensed User

    Why change the URL by a URL of my domain where there are also jpg images and do not read them?


    Code:
    ''Private MainUrl As String = "http://www.flickr.com/explore/interesting/7days/"

    Private MainUrl As String = "http://www.fmyURL.com/explore/interesting/7days/"
     
  17. DonManfred

    DonManfred Expert Licensed User

    It will not work using a url like yours.... You need to add the complete urls to the files to download them.
    like in post #1
    Code:
    links.Put(ImageView1, "http://www.basic4ppc.com/basic4android/images/SS-2012-08-29_12.55.42.png")
     
  18. Lowegaterecords

    Lowegaterecords Member Licensed User

    Hello as I can give the link to download the image through an edittext I'm using this code but it gives me an error in loading the bitmap.

    Code:
    Sub BTDownload_Click
        
    Dim links As Map

        links.Initialize
       
        
    If EditTextLink.Text<>"" Then
           
            links.Put(ImageViewResult,
    ""&EditTextLink.Text&"")
            CallSubDelayed2 (ImageDownloader, 
    "Download", collegamenti)
           
        Finisci se
       
    End Sub [/ CODE]
     
  19. DonManfred

    DonManfred Expert Licensed User

    1. You should always start a new thread for your questions.
    2- Which error??? It does NOT help at all if you hide it.
     
Thread Status:
Not open for further replies.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice