Android Question Downsampling image due to lack of memory.

Hi,

i try other alternative, one is to change the image downloader into :
B4X:
Sub JobDone(Job As HttpJob)

    ongoingTasks.Remove(Job.JobName)
    If Job.Success Then
        'Dim bmp As Bitmap = Job.GetBitmap
        'cache.Put(Job.JobName, bmp)
        If tasks.IsInitialized Then
            For i = 0 To tasks.Size - 1
                Dim link As String = tasks.GetValueAt(i)
                If link = Job.JobName Then
                    Dim iv As ImageView = tasks.GetKeyAt(i)
                    'Dim webview1 As WebView =tasks.GetKeyAt(i)
                    Log(iv)
                   
                '    iv.SetBackgroundImage(bmp)
                Dim out As OutputStream
                   
                    out = File.OpenOutput(File.DirInternalCache  , Main.nomernyo & ".jpg",True)
                   
                    File.Copy2(Job.GetInputStream,out)
                    out.close
                    iv.Bitmap = LoadBitmap(File.DirInternalCache, Main.nomernyo & ".jpg")
               
Main.nomernyo = Main.nomernyo + 1
                End If
            Next
        End If
    Else
        Log("Error downloading image: " & Job.JobName & CRLF & Job.ErrorMessage)
    End If
    Job.Release
   
End Sub
it goes well. but only like 25% better than previous code..

other than that i try to use webview to display the image.. which is significantly better.. but still in some point it will break too..

[
B4X:
WebView1.LoadHtml("<img src=" & links &"' width=100%>")

  Dim o As Reflector
o.Target = WebView1

o.RunMethod2("clearCache","False","java.lang.boolean")
any other alternative ?
 
Top