Android app: Headphone indicator

When I left my beloved N900 behind and bought a Wileyfox Swift Android phone, I noticed that the headphone socket did not work most of the times.

To debug this I needed a way to see when Android detects that the headphone is plugged in. There were no apps for this in F-Droid, but some in the Google Play store.

I installed the free-to-use one with the most downloads - Headphones Indicator by susomena. Starting it the first time played a full-screen video that then opened the browser. After that it worked as expected, showing an icon in the system bar on the top.

One thing that struck me was the size of the app when it downloaded: 2 MiB.

2MiB to display an icon

Really? Two megabytes to display a single icon? It was time to check what the app really does, and where the size comes from.

I extracted and decompiled the code, which got me 16 MiB of files:

12 MiB, Google APIs for Android
1.5 MiB, an XML parsing library, needed by adsdk
1.0 MiB
948 kiB, advertisement helper code
620 kiB, images and resources
104 kiB, more advertisement code
48 kiB, the actual application code

When using a disk usage analyzer on that code, the app's code was not even visible and disappeared in the company of the libraries that are included.

No wonder that such functionally tiny apps are making phones slower and slower.

Apart from displaying the advertisement, the app really did nothing more than displaying the earphone icon and providing two buttons to enable and disable this service.

My own headphone indicator

I wanted to prove that it could be much better, and implemented an open source app that displays if the headset is plugged in or not.

It has a tiny size of 12 kiB and can be downloaded, installed from F-Droid or Google Play. The source code is as always available on my git server and mirrored to GitHub.

Written by Christian Weiske.

Comments? Please send an e-mail.