Thursday, September 3, 2015

Java Refresh reducing use of ignorance++

Due to impending job interview stasis, Simon brushes up his Java skills.

Extends Application

So Android has a class called Application, you add it's name to your main manifest application decl and voilĂ  - a singleton object that represents lifetime of your application is yours for the managing.

A lot of Android tutorials jump straight to Activities and then go looking for something they need which they figure is a Service and the lifetime of the application starts looking like a right mess and before long....

I have now extended the Application class and, doh, if only I knew then...

Other Peoples Code

In the spirit of team work, I am using "other peoples code" today. Because Android is based on Java, which they stole in a similar manner to the way one would steal a handbag from an old woman, adding an SSH client to my productivity app turns out to be quite the delight.

Compared to the make hell that would have been C++ for this feature the jcraft jsch classes drop straight into project's source folder and voilĂ  - we have ssh client connection already. As usual  third party source is always educational if you take the time to browse:

// Some Cisco devices will miss to read '\n' if it is sent separately.
byte[] foo=new byte[V_C.length+1];
System.arraycopy(V_C, 0, foo, 0, V_C.length);
io.put(foo, 0, foo.length);