-2

I m trying to show image from URL but while showing image when i touch the screen or want to scroll than it show app not responding.

What i do on my code:-

  1. Inflate four different-2 type of xml on main screen in which I'm showing images which comes from URL.Its works fine but problem is my above heading of question.

     _______________________
    |           |           |
    |           |           |
    |     1     |     2     |
    |           |           |
    |_______________________|
    |           |           |
    |           |           |
    |     3     |     4     |
    |           |           |    
     _______________________
     many more inflating layout
    

    In above 1 , 2 , 3 and 4 xml some stuff with imageview.

  2. I'm trying so many link or lib file which shown below :

    SmartImageView LazyLoader
    Universal Image Loader

    Above mentioned LIB file working fine when using Gallery or listview but not works fine on my case.

many more which available when im doing google...

Code:

for(int i=0;i<10;i++)
{
    // inflate one ofI'm trying so many link or lib file which shown below :- four type of xml and run below Asyntask
}

Asyntask in which shown image and using Universal Image Loader to display image on imageview

        @Override
        protected void onPostExecute(String result) {
            super.onPostExecute(result);
            ControlPage.imageLoader.init(ImageLoaderConfiguration.createDefault(act));
            ControlPage.imageLoader.displayImage(values_of_book,cover_image_book_link, options);


        }
    }

Above im using Universal Image Loader lib file for showing image and its works fine on gallery view or list view but not in my case.

image which occure while loading image from url and we can touch the screen

enter image description here

duggu
  • 37,851
  • 12
  • 116
  • 113
  • 1
    it may create problem due to size of images . use any imageloader library. – Manoj Pal Jul 09 '13 at 05:12
  • @ManojPal im using "Universal Image Loader" lib for download. If u know better dan this so please let me know. – duggu Jul 09 '13 at 05:31
  • If, as you say, the problem comes when you touch the screen, then I think you need to show us the code for `ClickOnUserProfile.clickOnUserProfile`, and in addition LogCat output. The code you have currently shown does not help us find your problem. – Ken Y-N Jul 09 '13 at 06:19
  • @KenY-N on this funtion ClickOnUserProfile.clickOnUserProfile i'm start new activity but thing is that when ever i scroll the screen then above ANR is occur .... – duggu Jul 09 '13 at 06:38
  • Are you executing Asynctask inside for loop ? – kaushal trivedi Jul 09 '13 at 08:35
  • @kaushaltrivedi inside the onPostExecute method – duggu Jul 09 '13 at 09:32
  • 1
    you need to download the images in doInBackground() method..theres no use of Asynctask if u are not doing background processes in the background method...do the downloading in doInbackground() and do the UI interaction in onPostexecute method..also you should put the stacktrace that would help figure out what exactly is causing the problem – user632905 Jul 10 '13 at 11:36
  • I'M USING Universal Image Loader SO NO NEED TO DOWNLOAD IMAGE ON DO IN BACKGROUND IT HANDLE AUTOMATICALLY ON GALLERY OR LIST VIEW BUT NOT IN MY CASE – duggu Jul 10 '13 at 12:31
  • Why do you initialize the downloader in the post execute? I think this should be done only once per the whole application. – Boris Strandjev Jul 19 '13 at 19:57

1 Answers1

0

Those Image load libraries usually does load no the same Thread if the resource is already downloaded. This may freeze your screen, force async load of those and you will not receive any ANR.

Marcos Vasconcelos
  • 18,136
  • 30
  • 106
  • 167