Android LED Torch App

The most popular android torch apps ask for tons of ridiculous permissions. They want network access, memory access and just about every permission available. The ONLY permission actually needed is camera access. It’s very worrying to grant so many permissions to a simple torch app. Who knows what it’s doing behind the scenes? Thus I never downloaded one and decided to just write my own instead. After all, how hard could it be?

A search for “android torch app development” led to this article on Android Hive. The code is a bit old so one of the alert dialog functions has been deprecated. I also skipped the whole part about adding in sound effects and used a built in Switch instead of trying to do a fancy image switch.

I used the instructions on handling click events on the Toggle Button page instead of the alternative of adding an onCheckedChangeListener as suggested by the Android Hive tutorial.

That seemed simple enough. The program crashed when I tried it on the emulator, I didn’t debug it but guessed it was due to the lack of a torch on the emulator. The alert should have come up but the code was deprecated so perhaps API 19 doesn’t even have it. I might be wrong about this. Anyway, I loaded it onto my device, andddd nothing happened 😦

According to this StackOverflow thread, the flash won’t work for some devices without the SurfaceView and SurfaceHolder components. This other thread gives a lot more detail on how to implement it. The answer is complete, but the line “Your activity needs to implement SurfaceHolder.Callback” literally means something in code. Not obvious on an initial copy and paste.

public class MainActivity extends Activity implements SurfaceHolder.Callback {

Note the addition of implements SurfaceHolder.Callback
Without this bit, the function to add a callback to the SurfaceHolder will fail as the this object is the wrong type. This thread contributed to the required inspiration.

Another thing I had to do was to remove the camera.release() line to stop the program crashing with a null pointer exception when the flashlight is switched off then on again.

Here’s a screenshot of this very simple app.

image

Mass Delete Kindle Items

I have Instapaper setup to email my Kindle every week with the articles on my list. Over the year, I’ve gathered a huge number in the Kindle library.

While wondering how to clear them out today, I found a bookmarklet to mass destroy kindle items. This works very nicely. I can now mass delete all 15 items on a page at once instead of trying to do them one by one, which is ridiculous.

Rooting the Kindle Fire

After owning the Kindle Fire for nearly a year, I’ve decided that it’s time to try what I got it for in the first place. Using it as a relatively low cost Android tablet. A few Google searches seemed to suggest that Android Jelly Bean is available for the Kindle Fire and it would be a relatively simple process.

Naturally that didn’t turn out to be the case.

I started with a nice short looking tutorial at liliputing.com

The first step is to download the Kindle Fire Utility, and I immediately got stuck on the first step when install_drivers.bat didn’t work.

So I found instructions for manually rooting the Kindle Fire, which explains how to install the Android SDK and manually install the driver. When you run the SDK Manager, just install the Platform Tools and the Google USB Driver.

Next, following the instructions on another forum thread, I edited the driver files and tried to manually update the Kindle driver. Here, Windows 8 threw an error about the driver file being untrusted and totally refused to install it.

For a moment, I thought I would have to dig up an old copy of Windows and install it on a virtual machine or something, but it turns out that it’s possible to disable driver verification on Windows 8. Follow the instructions at laslow.net through a series of never seen before options. Repeat the steps for manually installing the driver through the Device Manager and it should complete successfully.

Now when I start run.bat in the Kindle Fire Utility, the ADB Status says online 🙂

Although the post title says rooting the Kindle Fire, this is as far as I’ve got so far, so the post will be updated as more progress is made.

Additional Reading

I came across the Kindle Fire for Beginners Guide on the XDA forums. It gives an excellent explanation of all the terms used and how all the components relate to each other.

Install Bootloader

Using the Kindle Fire Utility, I installed the FireFireFire bootloader. Based on the beginner’s guide, this seems to be the first step to getting other stuff installed. This is WRONG, installing the bootloader first prevents anything else from getting in as fastboot mode cannot be entered.