Android: the absolutely simplest thing

I have abandoned Windows Phone, and any development on it. I now have a Moto 4G, and I’m very pleased with it.

This is JUST about how to get the most basic of applications running on your Android phone, with 2 pre-requisites:

  • A Windows 10 box on which to develop the app. (I’m sure IOS etc work just as well, but I’m a Windows person).
  • An Android phone (because we will deploy directly to the phone, and not bother with an emulator)

This is a screenshot from my phone, representing Success. (Please note that deploying to the Play Store is not in scope: this is just for deploying to your own phones and tablets.) The “development” took 1 minute, the deployment to the phone took 1 minute, and it took longer that that to upload the screenshot from the phone to Google Photos:

Screenshot_20170731-233411.png

These are the steps:

  1. Install Android Studio

AnStudio012. In Android Studio, go to File/New/New Project, and follow this example, or if you know what you are doing, something like it. Then click Next (not shown here):

3. Target Android Devices… is what it says. Let’s say your phone and all your tablets are running Marshmallow. So follow this setup (else chose an alternative option against Minimum SDK), then click Next (not shown):

4. Add an Activity to Mobile. Pick Basic Activity, click Next, and on Customize the Activity, click Finish:

5. After about 20 seconds (on my laptop), the build completes, and you see this (I’ve compressed to save screen space), where “Hello World!” appears by default in the XML, and is rendered as a graphic

6. Running the app on your device. For this, let us use the real thing, not an emulator. Firstly, you need to get your phone in Developer mode. I won’t go into this here, but if you google [android tap seven times], you’ll find lots of advice.

Now hook up your phone or other device to your laptop or PC, using a cable you know can transfer data.

On the menu, select Run. This prompts Android Studio to look for a usable device. If your phone hookup went well, you see something like this:

AnStudio08

 

Click OK. It is not obvious that anything is happening, apart from the discrete bar at the bottom of the screen:

AnStudio09

After some seconds, you have this on your phone/device – I’ve used an actual photo of the phone rather than a screenshot, as evidence that the “app” really has gone directly to the phone. And that’s it. Sure, there’s a whole world of pain before you get to an app of any usefulness, but this was all about just showing the flow from PC via Android Studio to your phone.

LivePhone

But while we are here, a quick look at standards…

https://google.github.io/styleguide/javaguide.html

And this just cos I darn well liked it…

https://blog.codinghorror.com/new-programming-jargon/

Android: transferring files from PC to Android

  1. Android Phone: Settings/About Phone. Tap [Build Number] 7 times. After the first few taps it confirms you are on the right track
  2. Android Phone: Under Settings, search for [Developer options], and turn on [USB debugging]
  3. Android Phone: Still under [Developer options], tap [Select USB configuration], and select [MTP (Media Transfer Protocol)].
  4. PC / Android Phone: connect a USB cable between the two. Yes, sometimes a cable will allow charging, but fail silently when you are trying to connect. However, I find that is pretty rare. As you connect, assuming Audio is on, you should hear a confirming sound from the PC, at least. If things have gone REALLY well, you will see something like this in Windows Explorer:

AndroidTransfer01

Although I often forget the steps (hence this blog, at last), if I get to this point, then the subsequent file transfer from PC to Phone or tablet always succeeds, at least in my experience.

At the end of the file transfer session, probably good practice to turn off USB debugging.