I’ve created a preview release of MM in case Rob or anyone else needs/wants to show off the app to anyone. You can download it via directly typing in the download link, by doing an “adb install mobilemetagenomics.apk” if you have the sdk set up on your PC, or you can just use the Barcode Scanner app to scan and download directly from the QR-code behind the read-more cut. As I stated, this is a preview version of the code so many things are incomplete. I’ll try to update the .apk when I make signifcant changes, so check back for the latest version!
NOTE: Daniel just pointed out to me that you need to have a fasta file in the root directory of your SD Card for MM to actually do anything. You can transfer the file most easily by connecting your phone to a computer via USB, mounting the phone as a removable storage device, and then clicking and dragging the file from your PC to your phone. I’m unsure of where files are placed when a phone directly downloads a file, so the safest bet is to use the USB method.
Update (7/24/09): As far as I’m able to test (bioseed went down just before I could try it on a real phone), I have the dialog and the .txt and .mmr outputs both working! I’m pretty excited to finally have this section of the app coded; I actually agonized over the newlines for quite a while before realizing it was just Notepad displaying my results wrong… The .txt outputs display just fine in Wordpad and should also work for Mac and Linux (though linux may have those pesky ^M characters after each line). Unfortunately the java environment variables don’t help us in Android to determine what type of newlines the user will want when they email their file. I had to write the code with /r/n both in, because the file could be emailed to any operating system.
In this Nuts and Bolts entry, I’ll be discussing user interaction with User Interface elements, and how to code for it. Examples of most of these can be found in the Notepad Tutorial. There are several pieces of UI functionality that can be coded for, but the simplest and most obvious is the notion of “making the buttons work”. I imagine that, for most people new to Android, the obvious next step after laying out a fancy UI is to actually do something when the user interacts with it.
Check out the read more to find out how to do this and other UI related things!
Today I completed my trio of menu buttons for MM! That’s right folks, we have a Share Button!
If you can’t tell, I’m pretty excited about that. Not only because it took half a workday to do, but also because (in my opinion) it is a really cool feature. One of the things that most impressed me about my Ion when I first got it was that when browsing my pictures, there was a button with a pop up that asked what I wanted to do with it. In terms of MM, about the only reasonable thing I can think of to do with a .MMR output is to email it. So for now, that is what our share button does.
Another issue is that, as of right now, a .MMR is just a Serializable Array recorded to a file. It isn’t exactly very reader-friendly. This works fine if all we want to do is shoot a file across email to another android phone for viewing in their MM app, but we may want to look into more options in the future. The notion of sending an MMR across bluetooth to another phone is also interesting, but that would require a fair bit of digging to accomplish (and may not even be allowed, I’m not sure). Either way, I’m very happy to have accomplished the rough outline of what we want our menu buttons to do. At this point, adding more functionality will be pretty easy to do. Now if I could just add those nifty icons to my buttons…
Unfortunately I didn’t make it into the lab today to pick up my progress bar code, so that will have to wait until Monday, but I did make a lot of progress on MM! I coded a third Activity – this one is a pop-up dialog to ask the user what file they want to load. It gets displayed when they choose “load file” from the options menu. To go along with this, I coded full functionality for saving and loading files! I actually coded it twice, the first time it saved it to the phone’s storage, which I didn’t like. The new and final version saves files to the SDCard. I may add functionality to the save feature to name files whatever the user wants, but for now everything is saved as “filename.fa.mmr” MMR stands for Mobile Metagenomics Results filetype (which is actually just a serializable array dumped to a file).
And now my challenge to the lab! MM needs a cool icon for display on the Android phone. Right now it has the generic application window with a gear in front of it, and that is not only boring, but unprofessional. I’m absolute rubbish at art (digital or otherwise), so if somebody in the lab has a knack for it, feel free to make up a 48×48 PNG file for us! You can go with Rob’s tricorder theme, or any other idea you may have that applies. Translucent backgrounds work great as the phone will show the background theme through such a background (yes, I made some very crude artwork to test how this process works). If nobody in the lab feels up to the challenge, I’ll have to create a flat, pixelated masterpiece myself… (you’ve been warned!)
In my first real “Nuts and Bolts” entry, I’m going to discuss User Interface design. To avoid some redundancy, I ask that readers first work through Google’s Hello Android and a few of the Hello Views tutorials. These will give some familiarity with how to actually get Eclipse talking to Android, as well as teach a bit about the widgets available. What I intend to teach in this tutorial are the things that I didn’t find immediately obvious when going through the Google ones (though in my opinion they are actually pretty good).
Tonight I finally got the asynchronous downloads working perfectly for MM. I also coded the menu button to pop-up some of the options that we discussed at the meeting last week. I haven’t added my nice, pretty progress bar yet because I left the code on my work machine. I’ll probably stop in tomorrow to send myself that code really quick, though I’m sick (AGAIN!) so I’ll probably miss out on our lab activity 🙁
Most of my posts up until this point have avoided a real discussion of the actual code behind my Androids apps. I didn’t want to bore anybody with details they didn’t care about; but since it seems like some people do care, I’ll start sharing some Android coding tips! I also had the realization that if/when the lab has to replace me with another Android coder, that person may benefit from what I blog. Bus factor++ indeed!
Before I delve too far into things, I feel it would be worthwhile to think about some structure to this series of blog entries. For today I will blog some of my fresh discoveries, lest I forget them in typical programmer fashion! In the future, I will try to write a couple of entries a week with guides and gotchas written out for future Edwardslab (or any other) Android coders. Without further adieu, I shall explain a bunch of knowledge that just kicked my butt for the past couple of days! (See the Read More cut for random knowledge)
I’ve spent a while now working on little bits and pieces of code that I will need to eventually incorporate into Mobile Metagenomics. I’ve finally reached a point where I feel ready to move on to the next stage and start to synthesize all of these little ideas into something meaningful for MM. My goals for the next version essentially involve taking it out of a proof-of-concept stage and into a stage where it more or less ‘works’. I will probably leave the file browser and more friendly results view out, but most of the other goals from my talk should be included. I will at least establish a framework to later slot in all of the ideas that we discussed.
1. Download all 'file chunks' and display them.
2. Do this asynchronously, allowing the user to view results while work happens.
3. Split the program into a 'Search' Activity and a 'Results View' Activity.
4. Make the physical phone buttons work!
5. Eventually, code the rest of the event methods such that MM can be interrupted by a gTalk or gmail
notification and restart itself without loss of progress.
I had also been working on an app for myself after work, when I realized I was actually learning a lot of valuable things about more complex Android User Interface design. I may keep this around as a side project to work on for a few minutes here and there, when I need a quick break from MM. I think that learning some of the intricacies of Android UI will come in very handy in the future, and it will definitely help if I have a fun project as my learning platform!
Having just gone through the process from start to finish on a second phone, I thought I’d write a guide on exactly what is needed to root the Ion. Note that this is a guide specifically for the Ion, and does not apply to any other Magic / Sapphire / G2 / whatever that is not a Google Ion phone from I/O 2009.
One of the main things that came out of my Android tinkering today was knowledge of multi-threading. The threading technique used in GenomeSearch had ‘multiple’ threads as well (2), but the implementation was a bit lacking. Without going into too much detail, GenomeSearch has one (main) thread which manages the User Interface, and one background thread that blocks on network I/O. Unfortuantely, the implementation is such that if we had ever needed a third thread, we wouldn’t have been able to add it.
So, with a little help from this conversation on Android Beginners, I wrote up a little snippet to test running multiple background threads in addition to the main UI thread. You can find the code behind the cut (note that you will need to set up all of the other project files for this to work (layout, manifest, etc).