question

Gammill avatar image
Gammill asked

Fast menu pick problem

My app must generate a lot of coordinates. At greater than 2000 cells, I call an AsyncTask to do the calculations and display a progress bar. (The work does not need to be done in a separate thread; but it was how I got the progress bar to work nicely.) The problem: If the user hits the menu button fast, AsyncTask is called a second time before it has time to finish. No mater how I try, I can not catch the second menu pick (which causes the second call). It seems the second pick is there before any flag can be raised or the menu item disable. Any suggestions? (I am experienced PC programmer -- first major effort in Android. Never needed threads before. Maybe a wait/notify? If so how?)
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi Gammill, Thank you for your post. Can you please post the code what is creating problem?
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Gammill avatar image
Gammill answered
I just realized I am a Game Circle forum. This is not a Game Circle problem. I am sorry for posting in the wrong forum. (And the previous reply that closed before I meant it to,) No, I can not give you code -- to much involved. All works well IF the user does not tap the menu button real fast. My flags go up, the background process puts up the progress bar and I do not accept additional menu taps until it is finished (it interrupts cleanly with a back arrow). What I need is a way to slow down the menu taps. If fast tapped, I can not catch the tap just after my call to my AsyncTask class.. I know I am in the incorrect forum... What forum should I be in? This is my first post, my first Kindle Fire App. It is done and ready to go -- I just need to catch rapid menu taps.
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Gammill avatar image
Gammill answered
I have mostly solved my own problem. A sleep of 250 at the top of onOptionsItemSelected(), and clean up of to long of a sleep in my AsyncTask onCancel(). Allow my flags to go up and allow me to clean up. Apparently, multiple fast taps, cause Async's OnCancelListener() to be called. BUT... If I try... I can still cause a crash. But, I have to try very hard -- I call it solved. A user, will likely tap the menu fast; but I hope they will not just keep on tapping for a long time.
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.