Battles With the Android

As I have posted previously I am converting my PC application SecureIT to the Android smartphone platform.

I am coding this in Java, and having never used Java before it is turning out to be an interesting project. The PC version of the app can work with multiple data files; these files can be quite large and are also encrypted. Reading and decrypting the files can take some time. Processes that take a long time can be suspended by the Android operating system, so I had some difficulty in figuring out the correct approach to reading these files. I finally worked out how to do this in a background thread.

While I was testing this code I was using a hard-coded path to the data file, but in the final version I need to allow the user to browse for a file. As far as I can see, the Android system has no inbuilt API for file browsing so I am having to code this from scratch.  I have managed to retrieve a list of the available files, I now need to display these to the user and allow him/her to select one.  In Windows, I would just display a file open dialog, but the Android dialog will have to be built up from scratch.

The various elements of the application have to be broken down into separate chunks called Activities which need to be able to communicate with each other.  For example, adding a new entry to the database involves running a new Activity which collects the data from the user and updates the calling Activity. Editing an existing entry is even more involved, because we have to pass the original data to the new Activity, collect the user’s changes and return them to the calling Activity.  In Windows this would have been achieved with a modal dialog box which would not return until the user had entered the required data or decided to cancel the action.

Because of the nature of a mobile phone, apps can be interrupted at any time (for example, when the user answers a call). The app can even be interrupted by the user switching the orientation of the phone, from portrait to landscape or vice versa. This means that the developer has to cater for the possibility of their app suddenly being pushed to the background or even being closed completely.

Learning the API is particularly difficult because the official Android documentation is less than clear.  However, there are a lot of other resources on the internet including the Google groups.  I have been lurking in the android beginners group at Google groups, which was a wonderful source of information but that group has now been closed down.

All in all, the learning curve for Android is very steep but so far I am enjoying it. Hopefully, I will be able to persevere and not become demoralised.

Tags: ,

One Response to “Battles With the Android”

  1. Erick says:

    Step 1. Actually WRITE an app. Until you do that, EVERYTHING else is a waste of time.Step 2. Contact an EXISTING app store. No matter how good your app is, it is WORTHLESS if peolpe can’t find it.Step 3. The app store can help you with the rest.