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/

Advertisements

Amazon Drive: awful client

Having trialled Amazon Drive for 2 months, before it gets to 3 and pay-up time, I decided to go with OneDrive, as for 3 of us, that is good value. But I still needed to get my 300GB of data off Amazon and onto my external drive. And then the problems began: it seems that Amazon Drive does not tolerate anything other than the C drive. People have tried various workarounds such as symbolic links, editing the config json file, but these are hacks rather than supported options. After say 2 hours, I gave up, and found a good client called GoodSync, which does a nice job of giving visual feedback as the download progresses. Really makes the Amazon offering look feeble. And I just don’t understand why they have made such a mess of their own client offering. It is in such stark contrast to their constant reassessment of user interfaces for their other products. Odd.

 

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.

 

Github: file overlay icons

Summary: while apparently not a core part of Git/Github, the combination of Git Extensions and TortoiseGit does the job

Use case: within Windows/File Explorer, I want to see the status of my files relative to the Git repo, e.g. Added, Changed, Deleted, Unchanged

I googled…[file overlay icons github]

https://github.com/owncloud/client/wiki/Overlay-Icons ->

https://github.com/owncloud/client/issues/1818

I am very used to explorer icons in other source control systems, e.g. svn/Tortoise, and have taken them for granted. However, there seems to be a lot of huffing and puffing around the subject on the Git forums, with the opposite camps of “What on Earth do you want that for?” and “it is mad this is not available by default”.

This Stackoverflow post talks about [“GitExtensions is awesome for the true git experience. TortoiseGit obscures Git, forcing it into a “simple” experience. TortoiseGit has icon overlays though. The two work quite nicely together, so just install them both, use them for their strengths, and ignore them for their weaknesses.”]

Looking for one takes us here [https://github.com/gitextensions/gitextensions], here [https://github.com/gitextensions/gitextensions/releases/tag/v2.50.01]

and the other here [tortoisegit] and [https://tortoisegit.org/]

You will see from the last screenshot that it works well enough, imo.

 

 

 

Pester: pretty summaries

Short examples of a mix of passing and failing Pester tests being rendered in a browser, using ReportUnit, available on NuGet, and ingesting NUnit output format. Check out the browser screenshots below first for the end result.

Code

# Runs all test suites, passes the output to the NUnit format, renders it, displays in a browser

# see my article here for installing nuget via Choco:

# https://dennisaa.wordpress.com/2017/04/26/powershell-updating-jpg-metadata/

# https://www.nuget.org/packages/ReportUnit/

nuget.exe install ReportUnit

#Then, for example...

# Execute all the tests

$outputName = Get-Random

$outputFile = "$PSScriptRoot/$outputName.xml"

$htmlFile = "$PSScriptRoot/$outputName.html"

Invoke-Pester -PassThru -Strict -OutputFile $outputFile -OutputFormat NUnitXml

.\ReportUnit.1.2.1\tools\ReportUnit.exe $outputFile

Start-Process chrome $htmlFile