Skip to content
papuh

Building apps

The app on my phone

USB debugging, an install blocked on a Samsung, the first launch and reminders that need an exception from battery saving. And why the app has no internet access.

Treatment decisions are made by a doctor. This describes building an app, not advice.

An app outside the store

The app does not go through an app store. It is installed straight from the computer to the phone over a cable. For that, the phone needs Developer options turned on and USB debugging enabled in them. The computer then talks to the phone with a tool that comes with Android Studio.

Hurdle: Auto Blocker

Even so, the computer could not see the phone. The cause was the Samsung. One UI has a feature called Auto Blocker that blocks installing apps from outside the store and commands over the cable. While it is on, USB debugging does not work.

The fix was to turn it off temporarily, just for the install. The same thing happened again with the next update: the computer only saw the phone after Auto Blocker was off and USB debugging was on.

First launch

Installing is one command from the project’s start script. It builds the app and sends it to the phone. The app launched without crashing and showed the opening notice that it is only a calculator. My first comment was “the app is great”.

That was on the same day the AI wrote the first line of code.

What I use in the app

Without numbers, because I do not show the conversion here, but with how the app works in an ordinary week:

  • Home shows the active pen, what is left in it and the pen drawing with a scale. The plunger moves after every entry.
  • Pens holds several open pens at once, each with a colour, a status and the prescribed amount that I enter as my doctor set it.
  • Logging an injection asks for confirmation before saving. It stores the date, amount, pen, injection site and a note.
  • History shows all entries with a filter. An entry can be edited or deleted, and a deletion can be undone.
  • Schedule shows the date of the next injection by the interval, when the pen runs out, when its in-use period after opening ends and by when I need a new one.
  • Settings has export, restore, delete everything and the notice that the app is only a calculator.

Reminders and the battery

There are three kinds of reminders: injection, end of the pen’s in-use period and buying. The app schedules them in the Android system, so they arrive even when the app is closed. After the phone restarts or the app is updated, it sets them again.

Samsung has another quirk here. One UI restricts apps in the background to save battery, and reminders can then be late. Setting the app’s battery to “Unrestricted” helps. The app points this out in Settings and has a button that opens the right place in the system.

In the first test I did not explicitly confirm a reminder with the app closed. I only verified it in a later version with a test notification, which I write about in part five.

Privacy

For me this mattered as much as the calculation:

  • No internet. The app does not even ask the system for internet permission. It has no way to send anything.
  • No automatic backup. The data is in one file in the app’s internal storage and is excluded from the Google backup too.
  • Backup is manual. In Settings I export the data to a file and can restore it from there.
  • Nothing in the repository. The code and tests contain only made-up values, never real entries.

Two things to keep in mind

With an app outside the store I learned two things that would not have occurred to me with an ordinary app:

  1. An update does not delete data. A new version installs over the old one and the entries stay. That is why every new field in the data must have a default value, otherwise the app would not load the old file. If the file is unreadable, the app sets it aside and starts empty; it does not delete it.
  2. Uninstalling deletes everything. The app is signed with a key from my computer. A version built elsewhere will not install over it, and uninstalling would delete all entries. So before any such step, a manual export first.

So the first version was running. Then I started using it and the app started to grow. That is the next part.