Hi,

I was wondering if someone with better Android memory management skills than I have would like to give me some advice.

I needed the functionality that is in several iPhone apps that is : Shake the phone a couple of times when on certain activities and a spinning wheel pops up, spins at a speed determined by how hard you shake the phone, and then slows down randomly picks one of x number of items for you... I'm using it to help people who can't decide where to go to choose one of the top rated businesses that are on the map they are looking at.

Here's the issue: When I went looking for code to implement this I found this post and it looked like almost exactly what I wanted : http://stackoverflow.com/questions/2909249/how-can-we-create-iphone-like-spinners-in-android and it was... except that it only works with 2.0 and above. I wasn't really content with that, as I wanted to support all versions of Android in the same manner.

So.. using the above as a guide, I created my own version that relies heavily on Javascript and a timer to move the selections until it stops. The problem I'm having right now though is that when I try to run it a second time, it gets about half way through and crashes because of memory.

I need to decide exactly how I want to implement this, so that I can work on the memory issues with the final version: Right now I have a class called :

class SpinnerDialog
In the constructor, I pass the array of items to include in the Spinning Wheel, create an AlertDialog that has a WebView set as the View for the AlertDialog, and setup a WebChromeClient that loads the Javascript on the Page Load. Then I do a couple of calculations to decide how fast it should spin, create a timer, and move the items until the wheel stops. Then the user has the option of spinning it again... or choosing Ok.. and returning to the view they had before with the selected item highlighted. At this point the acceleromator functions are not hooked up to it.

I originally created this as a class just because it was easy to test most of the functions by creating it on a button click without much lag time. Now, I'm wondering if it should be a separate activity to help solve the memory issue, and manage the dialog a little better.

Sorry... this is a long winded post to ask a fairly simple question: What would be the ideal wrapper for this? The class has the advantage that I can put everything together (the accelerometer functions and the AlertDialog) and just drop it into any activity and create it. It can then wait for the shake and do it's own thing, sending a message to the activities handler when it's done. On the other hand, if I create it as an activity, the accelerometer functions would have to a separate class which would call the activity when the phone is shaken.

Any suggestions ??? Gotcha's or other comments... Need more info to be able to help?

FYI.. if anyone is looking for this... Once I have it stable, and I have the time, I can post the code under an open source licence.


Sincerely,

Brad Gies
-----------------------------------------------------------------------
Bistro Bot - Bistro Blurb
http://www.bgies.com
http://www.bistroblurb.com
http://www.ihottonight.com
-----------------------------------------------------------------------

Never doubt that a small group of thoughtful, committed people can
change the world. Indeed. It is the only thing that ever has - Margaret Mead

--
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

Reply via email to