Android Programming

Have you ever wondered how all those Android apps are produced? Would you like to be able to create one of your very own? If so, you need Android Studio, an integrated development environment (IDE) for Android programming, from Google.

This post is all Jeff’s fault! My buddy at the computer club developed an app that launches the club’s Internet home page simply by touching the associated icon. He used a web site that allowed him to “fill in the blanks” and create an Android Application Package (.apk file) that can be installed on a smartphone or tablet.

This started me thinking about what sort of app I could use and how I would go about creating it. Initially, I thought it might be useful to have a simple app that would display the contents of the SDcard on my ‘phone. Of course, I can do this in a couple of clicks using an existing file manager (right now ES File Explorer is my app of choice), and there may well be a specific app on the Play Store that would suit my requirement, but then there is the challenge of Android programming!

A couple of YouTube videos and Android tutorials later, I discovered that I should install Android Studio. I chose the Linux version and, as a test, opted to follow the instructions in an excellent video produced by Gary Sims at Android Authority (Writing your first Android app – everything you need to know) to create “my” first app.

There are a couple of wrinkles in the process. Firstly, the video suggests that you need to install the Java Development Kit (JDK) from Oracle before installing Android Studio (currently Version 2.2). However, the release notes for Studio indicate that: “…a single download includes everything you need to begin developing Android apps”. The latter certainly seems to be the case as I was able to develop my app without specifically installing the JDK.

Secondly, the Android Authority video was clearly produced using an earlier version of Studio. While the basic content is still useful, there are a number of differences in how some of the steps are applied due to a change in the user interface of the IDE. A second video (Android Studio Tutorial For Beginners – How To Build an Android App), by Mark Price, also uses an earlier version of Studio; however, the interface is very similar to that in the current release. So, by combining aspects of both videos, I was able to successfully create the test app. Note also that this second video also has more current details of the installation process for Studio, although the process is more-or-less automatic and very simple.

Once Android Studio has been installed and the initial setup process completed, I would recommend establishing a desktop launcher to easily run the program. On the Welcome Screen, click on the “Configure” link and then select “Create desktop entry”. This will create a “Programming” option in the main menu with an entry for “Android Studio”. Right-click on the latter option and select “Add to desktop”.

The final issue that I had was testing my app in the emulator. Clicking on the menu icon for the Android Virtual Device (AVD) Manager, did not display a default smartphone in the “Your Virtual Devices Menu”. I clicked on the button to “Create Virtual Device, selected “Nexus 5” as the test ‘phone, downloaded and selected “Lollipop x86 Android 5.1” as the OS, and changed the “Emulated Performance – Graphics” option to “Hardware – GLES 2.0”. Finally, I hit “Finish”, but nothing happened; there was still no listing for a virtual device. Then, I noticed an error message in the Event Log:

NoSuchFileException: /home/toaster/.android/avd/Nexus_5_API_22.ini

On checking, I found that there was no avd folder inside .android. So, I created one and tried once again to create the Nexus 5 virtual device. This time, the error message read:

AccessDeniedException: /home/toaster/.android/avd/Nexus_5_API_22.ini

Clearly, Android Studio was trying to write a file(s) to the .android/avd folder but there was some form of problem with permissions. Checking the permissions on .android (show hidden files, right-click on the .android folder, select Properties, and navigate to the Permissions tab) showed the Owner to be root. For some reason, when installing, Android Studio had created this folder with root access only but then, subsequently, was unable to create an avd folder and write out the virtual device files. My fix was to run “sudo caja”, giving myself root access, and change the owner of the .android folder to my username (toaster). With this change in place, the Nexus 5 virtual device could be successfully created and my app tested in the IDE’s emulator.

touchybutton

Finally, I was also able to create a .apk file (Build – Generate Signed APK), transfer it to my ‘phone, and install the app. So, now I have a little green man icon that displays a button which, when touched, says “Ouch!” Not terribly useful, but it did bring a smile to my face!

But, am I now ready to build my “real” app to display the contents of my SDcard? Well, perhaps not. A little research suggests that this is actually a rather complex process and requires a considerable amount of Java code. There are lots of examples on the web about how to implement such an app. Perhaps I will follow up when I have more time. But, for now, the requirement for a couple of clicks in my file manager doesn’t sound too onerous!

References:

ES File Explorer File Manager
https://play.google.com/store/apps/details?id=com.estrongs.android.pop&hl=en

Writing your first Android app – everything you need to know
https://www.youtube.com/watch?v=mAJeK283j0I

Android Studio Tutorial For Beginners – How To Build an Android App
https://www.youtube.com/watch?v=F-k5gwz_91o

Creating a simple file chooser
http://www.dreamincode.net/forums/topic/190013-creating-simple-file-chooser/

Simple Android File Chooser
https://rogerkeays.com/simple-android-file-chooser

aFileChooser – Android File Chooser
https://github.com/iPaulPro/aFileChooser

Posted in Android | Tagged , , | Leave a comment

Big Brother and Window Control Placement

Several years ago I found out how to switch the window controls from the left side to the right side of an active window. Now, it appears that the developers of the Unity desktop Ubuntu Linux have eliminated this option.
Continue reading

Posted in Mint, Tweaks, Ubuntu | Tagged , | Leave a comment

Running a bash script in a program launcher

I have always included a “read” command at the end of a bash script if I wanted to pause the script, and keep the terminal window open, after the pre-programmed command sequence terminated. Recently, instead of running a script by double-clicking inside the file manager, I tried to run it using a program launcher. I double-clicked on the desktop icon for the launcher, but nothing seemed to happen. The terminal window that would normally display the results of the script’s commands never opened. It turns out that one needs to take additional steps to see what is happening when using a program launcher.
Continue reading

Posted in Bash script, Mint | Tagged , | Leave a comment

Linux at 25

Happy Birthday Linux! Today marks the 25th anniversary of the announcement of work on the Linux kernel. “I’m doing a (free) operating system (just a hobby, won’t be big and professional like gnu)…” – Linus Torvalds, 25-Aug-91.
Continue reading

Posted in General | Leave a comment

Stop application windows snapping to full screen

Do you have an issue with moving a window by dragging it across the screen and it suddenly snapping (automatically maximizing) to full screen? If so, you let the top of the window touch the top of the screen and enabled automatic “snapping”. Fortunately, in Linux Mint, it’s a really easy fix.
Continue reading

Posted in Mint, Tweaks | Tagged , | Leave a comment

Opening Local HTML Files in Firefox under Android 6.0 (Marshmallow)

I use a local HTML file on all of my computing devices which lists all my frequently-used web sites on a multi-column page, with the individual entries being organized in categories. My new smartphone runs Android 6.0 which, for some reason seems to dislike opening the local HTML file in my favourite web browser, Mozilla Firefox.
Continue reading

Posted in Android, Applications | Tagged , | Leave a comment

Xed, Gedit, and Pluma in Mint 18

The default editor in Linux Mint 18 is Xed, a package that is based on Pluma, and which, according to Mint’s web site is meant to “…use traditional user interfaces…” and “…provide the functionality users already enjoy…” At face value, this is true, but when opening a file on my system, I quickly found it not to be the case.
Continue reading

Posted in Applications, Mint | Tagged , , , | 4 Comments