Back in spring-summer when I was studying for motorcycle licence, I put together an app to try exam questions with. It was super-simple, and took about one-two days worh of work. Python script scraped exam questions and illustrations from the official, HTML-driven test site and packaged them up neatly in SQLite database. The database (about 3MB) would be distributed with the app. The most interesting aspect was that pictures were encoded in WebP format to get the APK size down. Android doesn’t have built-in support for WebP until ICS, so I had to get my hands dirty with NDK and JNI.
So that was that. A really bare-bones app, but a fun weekend project. Now I’ve got another fun weekend project to share! The same idea and codebase fixed up to look better, and work better! Here it is on Android Market.
The notable changes:
- I’m still no artist/designer, but I think this one looks a bit better than the previous version
- I’m using newer version of libwebp, and the JNI bindings that are supplied with it. Byte array to Bitmap conversion in Java land is a bit more efficient too. Details here
- Move through question “cards” with swipes. I’m using ViewPager for this and I have to admit I’ve had a pleasant experience with it. Each question screen is a self-contained fragment. I wrote adapter that instantiates the fragments, and ViewPager takes care of the rest–creating new fragments when they are about to become visible, destroying fragments when they move further off-screen
- Encoded WebP pictures are not in SQLite database any more but in separate file now. The reason is this: A SQLite database bundled with the app (in
/res/raw) cannot be used, even if read-only, from these locations. It first has to be copied to internal or external storage. By storing pictures separately, I can keep the database size low (200KB or so), and waste less space with the duplicate copy
Cool stuff, in other news my car has engine knock. Android development is enjoyable once you learn the ropes, but now when I think about it, it would be so so insanely cool if I had the necessary expertise to work on engines of motor vehicles. Yeah, well THAT would be something!