Tag Archives: Update

ServiceProofOfConcept

Multitasking MM Update

So far I’ve learned some interesting things about services in Android. I also discovered that the issues with my build path (re: file manager troubles) are, well, known issues. Apparently the Android/Eclipse environment used to handle imports just fine, but nowadays it messes things up a bit when it builds .apk packages for phone deployment. A search on the Android Developers google group for ‘verify error’ turned up a detailed, though difficult for me to understand, explanation of exactly why Eclipse doesn’t build in method dependencies into apks. Either way, I’ve resolved myself to not importing methods – I’ll just cut and paste!

The AIDL tool for creating service interfaces is pretty cool, though a bit confusing to learn. From my current (limited) understanding, you can write Services which use Java primitives (and String… is that a primitive now?!), as well as any classes you write (provided you implement Parcelable!). As far as I’ve been able to discern, already-built classes like Hashtable are not in that list of usable classes. (Unless I change the class to implement parcelable, which I don’t have any real interest in doing…) Look for more on this tool when I have a better grasp of it – perhaps a future N&B article!

In my case, this unfortunately reduces me to the awkward approach of background threading for doing my JSON -> Hashtable conversion, list creation, and list sorting. Meanwhile, all http/cgi queries/uploads/downloads will be done in a background service. This approach isn’t terrible, however, as the difficult part to resume and recover would have been the download. If the background thread is interrupted, I can easily save the data and restart it when the app hits onResume(); Generally the time window on interrupting the sorting/list creation is a few seconds at most, so this will rarely come up.

The other issue I’ve been struggling with today is that for some reason my download buffer is coming up as expecting 0 bytes to download when I run it from the service. Ugh, and that took me 1+ hours to track down even with the awesome Eclipse debugger. I had sort of hacked it into the service when I finally got my initial test running, so I went back and reconstructed everything from the pure MM classes (which still work). I now have a sort of pseudo-MM set up inside of my service test app, which I’ll get to test first thing tomorrow!

Edit, 8/18/09, Morning: It helps when you give your program good values to run tests on… (peek behind the read more)

Continue reading

Multitasking Mobile Metagenomics

Triple M?! You betcha! Up until about five minutes ago, I was under the impression that when somebody navigated away from Mobile Metagenomics, I had to drop everything. I envisioned stopping my download thread, saving current results, saving iteration values, saving a mode variable, and whatever else was necessary to later restart whatever MM was doing. I even wrote pseudocode for it yesterday, and spent the first half of today implementing it.

I’m glad I decided to take a short break and read about Android stuff, because as it turns out I was flat out wrong about onStop(). Apparently, I can actually let my worker thread busily download new chunks of data into MM while a user is checking their email, making phone calls, IMing their friends about how cool Edwardslab is… And if the phone needs additional memory and has to kill the MM process, I believe I can actually store & create aforementioned variables at that point. Which is cool not only because we get to save our progress, but also because I don’t have to crumple up two pages of pseudocode Laughing

I was starting to feel like MM might be getting close to finished (unless Rob and I do some kind of cool file browser-esque navigation of results, in which case I’ll probably have to spend a week just learning the Biology), but now I have a new thing for my brain to chew on for a bit. I feel like doing the annotation downloads as a background process adds quite a bit of value to MM as an application. The user may choose to view the results as they happen (which is the original intent of Real-Time Metagenomics to begin with), but they will no longer be locked into MM. Even as a developer I hate the notion of “okay I started MM, now lets have it sit there for 3 minutes”, so I can only imagine how much users would’ve disliked that.

As far as progress since my last post about what I’m actually working on, I’ve got a fair amount of error detection/recovery implemented in both Genome Search and Mobile Metagenomics. I’m not going to say that I can detect and recover from everything (because I’m sure we’ll find some obscure way to break the app), but it is looking pretty solid from my tests. Through normal use, it shouldn’t do anything weird anymore. Note that ‘normal use’ still confines us to being locked inside of MM unless we want to lose all progress. That is, until I get this next part figured out!