code adventures

March 30, 2012

Dev-mode for your Android App

When you develop an App it is often useful to have some switches that allow you to gain more inside into what is going on. The classic example for such a feature is logging. Setting the log to a very noisy level can give you lots of extra information. In Android you can change the log level at runtime using the Android Developer Bridge (adb). Just run adb shell setprop log.tag.<your logtag> DEBUG to enable debug level logging.
But what if you want to bring up extra UI-elements, test different algorithms or even use different backends? A valid approach for this is to use a file that (if it exists) puts the App into dev mode. This works well in Android but is also quite static. A more dynamic switch is available by (ab)using the above log level mechanism. Just define a special logger (e.g. dev-mode) and check if it is set to debug level logging (using Log.isLoggable). This allows you to toggle dev-mode at runtime.
I implemented the above approach for a client who wanted a special dev-version for testing purposes. But in that case the dependence on the AndroidSDK (you need adb) was a concern, so we settled on the property file approach.
If you have any other ideas how to dynamically switch on additional features at runtime, I'd be happy to hear them.

January 23, 2012

ActionBar support

With Ice Cream Sandwich being on the rise now there is really no excuse for not supporting the ActionBar UI pattern anymore, even if you don't support a tablet version of your app. There are quite a few projects out there to help you with that.

Basic support is easily added thanks to the ActionBarCompat sample project that comes with the SDK. You can just copy that over into your project and have a consistent action bar (although very limited) across all Android versions.
It is also a nice example of how to abstract out platform-specific code. And consisting only of a couple of classes it is easy to understand and tweak. There is one little thing you should be aware of, though. The Home button is disabled in Ice Cream Sandwich by default, as described in this stackoverflow question).

For more complete action bar support have a look at ActionBarSherlock.

December 18, 2011

Keep track of your App's Market data

If you maintain any Apps in the Android Market then you have probably come across questions like
"How many downloads did the app have last week/month/year...?"
or
"Did the ratings improve since the last update?"
It's not easy to answer those questions since the Android Market's Developer console only gives you the current data. (There is statistics for active installs though.) So you have to keep track of these data yourself.
I found it quite tedious to do this by hand, so I built a little (Java) Selenium test that grabs the data and writes it to disk. Happily, it even runs headless, and can thus be easily put into the cloud. Lately, I fixed it up and put it on github. Hopefully this saves you some time, too.

February 25, 2011

Wallpaper still does not open

Lately, my Slider Live Wallpaper was "awarded" with a one-star rating again. The comment stated
"It wont even let me open it."
I've blogged about this problem before and now there is even an issue for it. As pointed out in the comments there you can work around this behavior by registering a special activity with the INFO category. This is what I'll do now. Here is a good how-to. But, unfortunately, you can not trigger the wallpaper selection directly, so the best you can do is displaying the list of all the installed live wallpapers. This is still somewhat limited for my taste.

So if anybody knows of a better way to handle this, please comment so that I can avoid above awards in the future.

September 29, 2010

Installing a wallpaper should be easier

Live wallpapers are great for showing off your Android phone, especially in an Android vs iPhone battle. Make sure to install "Show Off" from the market to be well-prepared.

A while ago I've done my first own live wallpaper. It is called "Slider" and is basically a 15-puzzle-like tile animation of an image selectable from the phone's gallery. It hasn't gained much attention (downloads) though. I wonder if many people try out live wallpapers regularly. Guess not, probably stick with a good one after a while.

Lately, I had a little email conversation with one (of the few) downloaders. It went like this:
DL: "Does not work!"
Me: "Could you explain..."
DL: "Does not open!"
Me: "Did you try HomeScreen>Menu>Wallpapers..."
DL: "That's not the problem, can not open, only uninstall."
Me: "Do any other live wallpapers work?"
DL: ">App will not open. no wallpapers at all. i do not know what do they look like. the app does not open..."
Me: "Live wallpapers are not applications, so you can not open them. This is why the button "open" does not work.You start a wallpaper from the menu "wallpapers" of your homescreen..."

This shows another problem with live wallpapers. Installing from the market is not as easy as it should be. I don't know why the "Open" button is just disabled, would be much better IMHO to at least let it open the list of installed wallpapers or the settings activity for the downloaded wallpaper. What do you think?

September 13, 2010

Android Market stats improvement suggestions

Lately, my minesweeper clone (called Mines) passed 50 000 downloads in the Android market. I uploaded the first version of the game in August 2009, so it took quite a while to get there. My users seem to be quite happy with the game though, at least I don't get too many ratings like "Rubbish" or "Uninstalled" ;-) and the rating average is still above 4. Also, the active installs are still above 40 percent.
Thinking of these numbers I came to realize that there are a couple of things I would like to know about the downloads/active installs but that is not provided by the market developer console.
  • I would like to have statistics over time.
  • I would like to filter over languages, would be great for comments/ratings also.
  • I would like to know how the game was found in the market.
The developer console has evolved over the last year, at least you get error stack traces, comments, and ratings numbers now. But there is still a lot of room for improvement.
For now I built a Selenium Test that runs once a day to grab the current download/rating numbers. That should at least allow for some basic statistics on these numbers.

April 23, 2010

Keep track of your android app stats

Lately, I fiddled around with the google gadget api again. One of the things I like to see on my igoogle page is the current stats of my android apps. Cyrket provides all the relevant data, but their page is to big to fit into a gadget. So I wrote a little gadget that extracts the basic data (rating average, number of ratings, number of comments) and shows just that.


Here it is.



About Me

codes for a living and also in his freetime, probably for lack of a real hobby. ;-)