What exactly does your onDestroy method look like?
My guess is that it looks like this:
* @Override*
* protected void onDestroy() {*
* super.onDestroy();*
* mImageFetcher.clearCache();*
* mImageFetcher.closeCache();*
* }*
I'm pretty sure that's an error. The last two lines will both create
threads, which creates a race condition.
There's a race between clearing the cache and closing it.
On Monday, April 15, 2013 12:13:34 PM UTC-5, tsioularisa wrote:
>
> I know that i start a new asynctask but it is the only way to auto clear
> the memories both lru and disk when the user exits the activity. first of
> all i use this (bad) technic because i don't want to waste the user's space
> with useless things for him and without let him know how much space do i
> need. Second in my application the user can navigate to this activity from
> the home activity using different image resources every time, so after a
> long time there will be a very big amount of things on the application's
> cache folder. how can i achieve to clear the cache folder every time the
> user leaves the activity without using this technic? also is this
> responsible for the problem i mentioned before? i am asking this because
> when i use only the wifi the problem never occurs no matter how many times
> the user will relaunch the activity.
> On Apr 15, 2013 6:56 PM, "bob" <[email protected] <javascript:>>
> wrote:
>
>> Why did you add
>>
>>
>> *mImageFetcher.clearCache()*?
>>
>>
>> You do realize that starts a new AsyncTask, don't you?
>>
>>
>> Starting a new AsyncTask sounds like a really bad idea in onDestroy().
>>
>>
>>
>> On Sunday, April 14, 2013 5:07:23 PM UTC-5, tsioularisa wrote:
>>>
>>> i am using the bitmapfun example and the only part of the code that i
>>> have changed is in the class imageGridFragment, where i have added the
>>> mImageFetcher.clearCache() in the onDestroy() before the call
>>> of mImageFetcher.closeCache();**. The problem that i have found is that
>>> when i launch the app and starting downloading the images via wifi
>>> everything is ok. After that i close the app and the wifi, open the 3G and
>>> relaunch the application again. Also this time everything works fine. Most
>>> of the times if i close the data network and reopen the wifi i can't
>>> donwload the images. The logcat is the following when the problem occurs:
>>>
>>> 04-15 00:41:16.870: D/ImageCache(4141): Memory cache created (size =
>>> 16384)
>>> 04-15 00:41:16.940: D/ImageWorker(4141): cancelPotentialWork - cancelled
>>> work for https://lh6.googleusercontent.**com/-55osAWw3x0Q/URquUtcFr5I/**
>>> AAAAAAAAAbs/rWlj1RUKrYI/s160-**c/A%252520Photographer.jpg<https://lh6.googleusercontent.com/-55osAWw3x0Q/URquUtcFr5I/AAAAAAAAAbs/rWlj1RUKrYI/s160-c/A%252520Photographer.jpg>
>>> 04-15 00:41:16.940: D/ImageGridFragment(4141): onCreateView - numColumns
>>> set to 3
>>> 04-15 00:41:16.960: D/ImageWorker(4141): cancelPotentialWork - cancelled
>>> work for https://lh6.googleusercontent.**com/-55osAWw3x0Q/URquUtcFr5I/**
>>> AAAAAAAAAbs/rWlj1RUKrYI/s160-**c/A%252520Photographer.jpg<https://lh6.googleusercontent.com/-55osAWw3x0Q/URquUtcFr5I/AAAAAAAAAbs/rWlj1RUKrYI/s160-c/A%252520Photographer.jpg>
>>> 04-15 00:41:16.960: D/ImageWorker(4141): cancelPotentialWork - cancelled
>>> work for https://lh4.googleusercontent.**com/--dq8niRp7W4/URquVgmXvgI/**
>>> AAAAAAAAAbs/-gnuLQfNnBA/s160-**c/A%252520Song%252520of%**
>>> 252520Ice%252520and%**252520Fire.jpg<https://lh4.googleusercontent.com/--dq8niRp7W4/URquVgmXvgI/AAAAAAAAAbs/-gnuLQfNnBA/s160-c/A%252520Song%252520of%252520Ice%252520and%252520Fire.jpg>
>>> 04-15 00:41:16.960: D/ImageWorker(4141): cancelPotentialWork - cancelled
>>> work for https://lh5.googleusercontent.**com/-7qZeDtRKFKc/URquWZT1gOI/**
>>> AAAAAAAAAbs/hqWgteyNXsg/s160-**c/Another%252520Rockaway%**
>>> 252520Sunset.jpg<https://lh5.googleusercontent.com/-7qZeDtRKFKc/URquWZT1gOI/AAAAAAAAAbs/hqWgteyNXsg/s160-c/Another%252520Rockaway%252520Sunset.jpg>
>>> 04-15 00:41:16.960: D/ImageWorker(4141): cancelPotentialWork - cancelled
>>> work for https://lh3.googleusercontent.**com/--L0Km39l5J8/URquXHGcdNI/**
>>> AAAAAAAAAbs/3ZrSJNrSomQ/s160-**c/Antelope%252520Butte.jpg<https://lh3.googleusercontent.com/--L0Km39l5J8/URquXHGcdNI/AAAAAAAAAbs/3ZrSJNrSomQ/s160-c/Antelope%252520Butte.jpg>
>>> 04-15 00:41:16.960: D/ImageWorker(4141): cancelPotentialWork - cancelled
>>> work for https://lh6.googleusercontent.**com/-8HO-4vIFnlw/URquZnsFgtI/**
>>> AAAAAAAAAbs/WT8jViTF7vw/s160-**c/Antelope%252520Hallway.jpg<https://lh6.googleusercontent.com/-8HO-4vIFnlw/URquZnsFgtI/AAAAAAAAAbs/WT8jViTF7vw/s160-c/Antelope%252520Hallway.jpg>
>>> 04-15 00:41:16.960: D/ImageWorker(4141): cancelPotentialWork - cancelled
>>> work for https://lh4.googleusercontent.**com/-WIuWgVcU3Qw/URqubRVcj4I/**
>>> AAAAAAAAAbs/YvbwgGjwdIQ/s160-**c/Antelope%252520Walls.jpg<https://lh4.googleusercontent.com/-WIuWgVcU3Qw/URqubRVcj4I/AAAAAAAAAbs/YvbwgGjwdIQ/s160-c/Antelope%252520Walls.jpg>
>>> 04-15 00:41:16.960: D/ImageWorker(4141): cancelPotentialWork - cancelled
>>> work for https://lh6.googleusercontent.**com/-UBmLbPELvoQ/URqucCdv0kI/**
>>> AAAAAAAAAbs/IdNhr2VQoQs/s160-**c/Apre%2525CC%252580s%**
>>> 252520la%252520Pluie.jpg<https://lh6.googleusercontent.com/-UBmLbPELvoQ/URqucCdv0kI/AAAAAAAAAbs/IdNhr2VQoQs/s160-c/Apre%2525CC%252580s%252520la%252520Pluie.jpg>
>>> 04-15 00:41:16.960: D/ImageWorker(4141): cancelPotentialWork - cancelled
>>> work for https://lh3.googleusercontent.**com/-s-AFpvgSeew/URquc6dF-JI/**
>>> AAAAAAAAAbs/Mt3xNGRUd68/s160-**c/Backlit%252520Cloud.jpg<https://lh3.googleusercontent.com/-s-AFpvgSeew/URquc6dF-JI/AAAAAAAAAbs/Mt3xNGRUd68/s160-c/Backlit%252520Cloud.jpg>
>>> 04-15 00:41:16.960: D/ImageWorker(4141): cancelPotentialWork - cancelled
>>> work for https://lh5.googleusercontent.**com/-bvmif9a9YOQ/URquea3heHI/**
>>> AAAAAAAAAbs/rcr6wyeQtAo/s160-**c/Bee%252520and%252520Flower.**jpg<https://lh5.googleusercontent.com/-bvmif9a9YOQ/URquea3heHI/AAAAAAAAAbs/rcr6wyeQtAo/s160-c/Bee%252520and%252520Flower.jpg>
>>> 04-15 00:41:16.960: D/ImageWorker(4141): cancelPotentialWork - cancelled
>>> work for https://lh5.googleusercontent.**com/-n7mdm7I7FGs/URqueT_BT-I/**
>>> AAAAAAAAAbs/9MYmXlmpSAo/s160-**c/Bonzai%252520Rock%**252520Sunset.jpg<https://lh5.googleusercontent.com/-n7mdm7I7FGs/URqueT_BT-I/AAAAAAAAAbs/9MYmXlmpSAo/s160-c/Bonzai%252520Rock%252520Sunset.jpg>
>>> 04-15 00:41:16.960: D/ImageWorker(4141): cancelPotentialWork - cancelled
>>> work for https://lh6.googleusercontent.**com/-4CN4X4t0M1k/URqufPozWzI/**
>>> AAAAAAAAAbs/8wK41lg1KPs/s160-**c/Caterpillar.jpg<https://lh6.googleusercontent.com/-4CN4X4t0M1k/URqufPozWzI/AAAAAAAAAbs/8wK41lg1KPs/s160-c/Caterpillar.jpg>
>>> 04-15 00:41:16.960: D/ImageWorker(4141): cancelPotentialWork - cancelled
>>> work for https://lh3.googleusercontent.**com/-rrFnVC8xQEg/URqufdrLBaI/**
>>> AAAAAAAAAbs/s69WYy_fl1E/s160-**c/Chess.jpg<https://lh3.googleusercontent.com/-rrFnVC8xQEg/URqufdrLBaI/AAAAAAAAAbs/s69WYy_fl1E/s160-c/Chess.jpg>
>>> 04-15 00:41:16.960: D/ImageWorker(4141): cancelPotentialWork - cancelled
>>> work for https://lh5.googleusercontent.**com/-WVpRptWH8Yw/URqugh-QmDI/**
>>> AAAAAAAAAbs/E-MgBgtlUWU/s160-**c/Chihuly.jpg<https://lh5.googleusercontent.com/-WVpRptWH8Yw/URqugh-QmDI/AAAAAAAAAbs/E-MgBgtlUWU/s160-c/Chihuly.jpg>
>>> 04-15 00:41:16.960: D/ImageWorker(4141): cancelPotentialWork - cancelled
>>> work for https://lh5.googleusercontent.**com/-0BDXkYmckbo/URquhKFW84I/**
>>> AAAAAAAAAbs/ogQtHCTk2JQ/s160-**c/Closed%252520Door.jpg<https://lh5.googleusercontent.com/-0BDXkYmckbo/URquhKFW84I/AAAAAAAAAbs/ogQtHCTk2JQ/s160-c/Closed%252520Door.jpg>
>>> 04-15 00:41:16.960: D/ImageWorker(4141): cancelPotentialWork - cancelled
>>> work for https://lh3.googleusercontent.**com/-PyggXXZRykM/URquh-kVvoI/**
>>> AAAAAAAAAbs/hFtDwhtrHHQ/s160-**c/Colorado%252520River%**252520Sunset.jpg<https://lh3.googleusercontent.com/-PyggXXZRykM/URquh-kVvoI/AAAAAAAAAbs/hFtDwhtrHHQ/s160-c/Colorado%252520River%252520Sunset.jpg>
>>> 04-15 00:43:10.100: D/ImageWorker(4141): cancelPotentialWork - cancelled
>>> work for https://lh6.googleusercontent.**com/-55osAWw3x0Q/URquUtcFr5I/**
>>> AAAAAAAAAbs/rWlj1RUKrYI/s160-**c/A%252520Photographer.jpg<https://lh6.googleusercontent.com/-55osAWw3x0Q/URquUtcFr5I/AAAAAAAAAbs/rWlj1RUKrYI/s160-c/A%252520Photographer.jpg>
>>> 04-15 00:43:10.100: D/ImageWorker(4141): cancelPotentialWork - cancelled
>>> work for https://lh4.googleusercontent.**com/--dq8niRp7W4/URquVgmXvgI/**
>>> AAAAAAAAAbs/-gnuLQfNnBA/s160-**c/A%252520Song%252520of%**
>>> 252520Ice%252520and%**252520Fire.jpg<https://lh4.googleusercontent.com/--dq8niRp7W4/URquVgmXvgI/AAAAAAAAAbs/-gnuLQfNnBA/s160-c/A%252520Song%252520of%252520Ice%252520and%252520Fire.jpg>
>>> 04-15 00:43:10.100: D/ImageWorker(4141): cancelPotentialWork - cancelled
>>> work for https://lh5.googleusercontent.**com/-7qZeDtRKFKc/URquWZT1gOI/**
>>> AAAAAAAAAbs/hqWgteyNXsg/s160-**c/Another%252520Rockaway%**
>>> 252520Sunset.jpg<https://lh5.googleusercontent.com/-7qZeDtRKFKc/URquWZT1gOI/AAAAAAAAAbs/hqWgteyNXsg/s160-c/Another%252520Rockaway%252520Sunset.jpg>
>>> 04-15 00:43:10.100: D/ImageWorker(4141): cancelPotentialWork - cancelled
>>> work for https://lh3.googleusercontent.**com/--L0Km39l5J8/URquXHGcdNI/**
>>> AAAAAAAAAbs/3ZrSJNrSomQ/s160-**c/Antelope%252520Butte.jpg<https://lh3.googleusercontent.com/--L0Km39l5J8/URquXHGcdNI/AAAAAAAAAbs/3ZrSJNrSomQ/s160-c/Antelope%252520Butte.jpg>
>>> 04-15 00:43:10.100: D/ImageWorker(4141): cancelPotentialWork - cancelled
>>> work for https://lh6.googleusercontent.**com/-8HO-4vIFnlw/URquZnsFgtI/**
>>> AAAAAAAAAbs/WT8jViTF7vw/s160-**c/Antelope%252520Hallway.jpg<https://lh6.googleusercontent.com/-8HO-4vIFnlw/URquZnsFgtI/AAAAAAAAAbs/WT8jViTF7vw/s160-c/Antelope%252520Hallway.jpg>
>>> 04-15 00:43:10.100: D/ImageWorker(4141): cancelPotentialWork - cancelled
>>> work for https://lh4.googleusercontent.**com/-WIuWgVcU3Qw/URqubRVcj4I/**
>>> AAAAAAAAAbs/YvbwgGjwdIQ/s160-**c/Antelope%252520Walls.jpg<https://lh4.googleusercontent.com/-WIuWgVcU3Qw/URqubRVcj4I/AAAAAAAAAbs/YvbwgGjwdIQ/s160-c/Antelope%252520Walls.jpg>
>>> 04-15 00:43:10.100: D/ImageWorker(4141): cancelPotentialWork - cancelled
>>> work for https://lh6.googleusercontent.**com/-UBmLbPELvoQ/URqucCdv0kI/**
>>> AAAAAAAAAbs/IdNhr2VQoQs/s160-**c/Apre%2525CC%252580s%**
>>> 252520la%252520Pluie.jpg<https://lh6.googleusercontent.com/-UBmLbPELvoQ/URqucCdv0kI/AAAAAAAAAbs/IdNhr2VQoQs/s160-c/Apre%2525CC%252580s%252520la%252520Pluie.jpg>
>>> 04-15 00:43:10.100: D/ImageWorker(4141): cancelPotentialWork - cancelled
>>> work for https://lh3.googleusercontent.**com/-s-AFpvgSeew/URquc6dF-JI/**
>>> AAAAAAAAAbs/Mt3xNGRUd68/s160-**c/Backlit%252520Cloud.jpg<https://lh3.googleusercontent.com/-s-AFpvgSeew/URquc6dF-JI/AAAAAAAAAbs/Mt3xNGRUd68/s160-c/Backlit%252520Cloud.jpg>
>>> 04-15 00:43:10.110: D/ImageWorker(4141): cancelPotentialWork - cancelled
>>> work for https://lh5.googleusercontent.**com/-bvmif9a9YOQ/URquea3heHI/**
>>> AAAAAAAAAbs/rcr6wyeQtAo/s160-**c/Bee%252520and%252520Flower.**jpg<https://lh5.googleusercontent.com/-bvmif9a9YOQ/URquea3heHI/AAAAAAAAAbs/rcr6wyeQtAo/s160-c/Bee%252520and%252520Flower.jpg>
>>> 04-15 00:43:10.110: D/ImageWorker(4141): cancelPotentialWork - cancelled
>>> work for https://lh5.googleusercontent.**com/-n7mdm7I7FGs/URqueT_BT-I/**
>>> AAAAAAAAAbs/9MYmXlmpSAo/s160-**c/Bonzai%252520Rock%**252520Sunset.jpg<https://lh5.googleusercontent.com/-n7mdm7I7FGs/URqueT_BT-I/AAAAAAAAAbs/9MYmXlmpSAo/s160-c/Bonzai%252520Rock%252520Sunset.jpg>
>>> 04-15 00:43:10.110: D/ImageWorker(4141): cancelPotentialWork - cancelled
>>> work for https://lh6.googleusercontent.**com/-4CN4X4t0M1k/URqufPozWzI/**
>>> AAAAAAAAAbs/8wK41lg1KPs/s160-**c/Caterpillar.jpg<https://lh6.googleusercontent.com/-4CN4X4t0M1k/URqufPozWzI/AAAAAAAAAbs/8wK41lg1KPs/s160-c/Caterpillar.jpg>
>>> 04-15 00:43:10.110: D/ImageWorker(4141): cancelPotentialWork - cancelled
>>> work for https://lh3.googleusercontent.**com/-rrFnVC8xQEg/URqufdrLBaI/**
>>> AAAAAAAAAbs/s69WYy_fl1E/s160-**c/Chess.jpg<https://lh3.googleusercontent.com/-rrFnVC8xQEg/URqufdrLBaI/AAAAAAAAAbs/s69WYy_fl1E/s160-c/Chess.jpg>
>>> 04-15 00:43:10.110: D/ImageWorker(4141): cancelPotentialWork - cancelled
>>> work for https://lh5.googleusercontent.**com/-WVpRptWH8Yw/URqugh-QmDI/**
>>> AAAAAAAAAbs/E-MgBgtlUWU/s160-**c/Chihuly.jpg<https://lh5.googleusercontent.com/-WVpRptWH8Yw/URqugh-QmDI/AAAAAAAAAbs/E-MgBgtlUWU/s160-c/Chihuly.jpg>
>>> 04-15 00:43:10.110: D/ImageWorker(4141): cancelPotentialWork - cancelled
>>> work for https://lh5.googleusercontent.**com/-0BDXkYmckbo/URquhKFW84I/**
>>> AAAAAAAAAbs/ogQtHCTk2JQ/s160-**c/Closed%252520Door.jpg<https://lh5.googleusercontent.com/-0BDXkYmckbo/URquhKFW84I/AAAAAAAAAbs/ogQtHCTk2JQ/s160-c/Closed%252520Door.jpg>
>>> 04-15 00:43:10.110: D/ImageWorker(4141): cancelPotentialWork - cancelled
>>> work for https://lh3.googleusercontent.**com/-PyggXXZRykM/URquh-kVvoI/**
>>> AAAAAAAAAbs/hFtDwhtrHHQ/s160-**c/Colorado%252520River%**252520Sunset.jpg<https://lh3.googleusercontent.com/-PyggXXZRykM/URquh-kVvoI/AAAAAAAAAbs/hFtDwhtrHHQ/s160-c/Colorado%252520River%252520Sunset.jpg>
>>> 04-15 00:43:12.930: D/CLIPBOARD(4141): Hide Clipboard dialog at Starting
>>> input: finished by someone else... !
>>> 04-15 00:43:28.550: D/dalvikvm(4141): GC_EXPLICIT freed 208K, 49% free
>>> 3384K/6599K, external 993K/2209K, paused 56ms
>>>
>>> For the recreation of the problem i open the app only in the
>>> gridactivity(i don't click any imageview) and i reopen the app after i
>>> switch between wifi and data network. I don't know when exactly the problem
>>> happens but in most of the cases the problem appears in the 3rd time! My
>>> guess is that when i close the app and reopen it some tasks are still in
>>> memory. I don't know why this situation can cause a problem but as i see in
>>> the above example none of these images starts processing!
>>>
>> --
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to
>> [email protected]<javascript:>
>> To unsubscribe from this group, send email to
>> [email protected] <javascript:>
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en
>> ---
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Android Developers" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/android-developers/n09usWJCWh4/unsubscribe?hl=en
>> .
>> To unsubscribe from this group and all its topics, send an email to
>> [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.