Edwards Lab

Delivering the best in bioinformatics...

Static on my Android

This post is mostly to document a pretty tricky little 'gotcha' in Android, but I'll give some background on how I discovered it as well. I've been wrestling with a minor bug in MtgHelper lately, mainly for something to do / something to keep me sharp. (RTMg.mob is in a holding pattern at present until Rob has time to tweak the CGI a little.)

Essentially the bug deals with how my two main application modes interact. Normally, MtgHelper operates from an Activity bearing the same name. There is an alternate view mode which operates from the Head2HeadMode Activity which splits the screen and changes how some methods work as a result. In particular, Head to Head ignores orientation changes.

The bug occurs in head to head mode when the user 'changes orientation' and then presses the back button. A second copy of the Head2HeadMode activity gets created, so the app gives the illusion of needing to press the Back button twice to get back to the home screen.

I ran into a very interesting snag when trying a solution to correct this bug. I created a static boolean variable (so that I could share it across my two activities without bundling it with my other data). Instead of painstakingly coding the state-saving stuff in the several places it would be needed, I wanted the variable to live and die with the application's Activities. Interestingly, due to the static variable declaration, the variable was seeming to outlive the application!

As it turns out, even when you use the Back button in Android to completely close an application by taking all of the activities off of the stack, there can still be an Activity process lingering around for a while. This process is every bit as entitled as anything else to have static access to your variable. This results in unpredictable behavior wherein the variable appears to save state sometimes, but may not always. If Android decides to garbage collect my lingering process, the static goes with it.

MM Icon!

We finally have icon / advertising artwork for RTMg.mob (MM). It took us a while to wrangle up an artist, but we eventually got my girlfriend (Melissa Metheney) to do the art for us!

Here are the large (ad sized) images :)

Using windows 'safely'

This topic has come up a few times in the lab recently, so I decided to write a guide on it. I'll omit the Linux advertisement, but if you are going to (or have to) use windows for something, here are some good practices. All of these tools are (at the time of this writing) free to the public for home use.

Back up important stuff. This goes for everyone, actually. (Never mind the bit about me not practicing what I preach...)

Use avast! antivirus. It is fairly unobtrusive and has its virus definitions updated really often. If you don't like avast!, people alternatively use AVG (although they're getting better and better at hiding the free version). I believe that both programs come set up automatically, but you should make sure that your software is A. updating itself regularly and B. actually performing scans at some point.

Anti-spyware stuff tends to be good too. Antivirus will catch some of this, and they're better and better at it lately, but I still prefer to use a cocktail of anti-bad-stuff on my windows machines. I recommend using a combination of Spybot Search & Destroy and Ad-Aware. NOTE: it seems that, unfortunately, Ad-Aware has gone the way of ZoneAlarm. The link to the free version exists but is broken. Gross. If you can find a free version of it please post the link. Otherwise, I must unfortunately recommend that readers do not install Ad-Aware by jumping through the hoop of their stupid "complete one offer" scam. Be sure to update your anti-spyware after you install it. Spybot in particular has an "Immunize" function in addition to scanning. This is perhaps the biggest motivator for installing spybot. Blocking spyware entirely is awesome, and makes sure you waste less time removing stuff over and over.

Use Firefox. (Chrome seems cool too, but I don't have any tips for securing Chrome, or much knowledge about it in general). Lock down your Firefox using NoScript and AdBlock Plus. NOTE: After installing these two plugins, websites are going to look a little...different. Particularly NoScript. There will be a little 'S' in the bottom right hand corner of your Firefox now that you will often have to click and tell it to 'allow' scripts from certain trusted websites. This can be annoying at first, but is worth the added security, especially if you tell it to remember your choice and always trust Google.com, slashdot.org, sourceforge.net, Edwardslab.sdsu.edu or whatever. Basically, any site you know isn't trying to do something to your computer you can trust, but beware that the plugin is only as good as your decisions are.

I also recommend WebOfTrust for finding out what websites are shady or not in the first place.

I hope these links help you secure your Windows install. If you have any questions about using the aforementioned software, feel free to ask in the comments or email me and I'll do my best to help!

Making Android Videos

Since I agonized over how to make these videos both times I did it, I thought I'd write up a guide. I'll assume that readers have already developed an Android application (or whatever else they want to take video of) and know how to run it for display.

To capture the video, I reccomend using Ubuntu and downloading gtk-recordMyDesktop. All of the mac/windows utilities I've found are paid and while some (read: Fraps) are pretty reasonably priced for the quality of the tool, free is always nice. Gtk will also record screen regions easily, which is ideal if, like me, you only want a portion of your screen recorded. In my case, I draw the record region around the mock cell phone displayed by the Android emulator. The program will output a .ogv file when recording is done.

To get this file into a format that your video editing software will care about, you have to do a little file format dance as follows. Open a terminal window. Write: ffmpeg -i inputFileName -b 5000k outputFileName.desiredFormat  (inputFileName is your output file from gtk. outputFileName is what you want the transcoder to spit out at the end. desiredFormat is .mov if you're using iMovie.)

I'd like to note that I didn't come up with that nice command-line jutsu on my own. I found it after Googling around for a while. I'm not entirely sure what all of those flags are for as I didn't actually read the man page on ffmpeg.

Next, boot up your mac or whatever, transfer the files over, and edit away! Happy movie making!

AAAS Breakfast w/ Scientists

This morning I went to the AAAS breakfast with Rob, Liz, and Ramy. I can't say enough good things about the experience! The venue was great, the food was good, and the students were awesome!

I was really impressed by the quality of their research. It seemed like a lot of the projects were very much real, useful research endeavors that demonstrate a wealth of potential. I found that I got a lot out of speaking with the students, and I did my best to give them worthwhile tips about college and research. (The tips about research basically amounted to: "do research. it is awesome. free trips!")

More than anything I was surprised by how far along a lot of these students are, compared to what I was doing when I was in high school. I truly feel that they all have promising careers in science ahead of them should they continue on that path. I would highly recommend attending future breakfasts; you will get at least as much out of it as the students do! And besides, you can't beat a free breakfast, right? Right?!

You are here: Home Josh