Native Android Programming

A few important Android programming-related websites

[ pic of Android's green robot ]

Android Studio rocks (well, it did back in 2013) !

Google's IDE is based upon the "IntelliJ IDE" (I had started using IntelliJ's Community-edition, before I 'graduated' to Android-Studio.)
(Until Android-Studio came along, Google recommended their Android-plugin, for use with the Eclipse IDE.)

Android Studio installation comments!

I noticed during my 2017 installation, at the beginning, their default installation placement was interesting. I noticed that they place the Studio itself in the location: "C:\Program Files\Android\Android Studio", and they place the Android SDK down into your 'AppData/Local' area at: "C:\Users\David\AppData\Local\Android\sdk". I just find this comment-worthy, as this is first time I've ever noticed a product mentioning the use of this area. This could become helpful if you ever needed to manually inspect or clean/delete such areas, etc.

Commonsware.com - lots of example Native-Android code available here.

What's coolest about CommonsWare, is that all their source-code examples are open-source and on GitHub.com!

Yes, I HAVE now subscribed to their 2000+ page ebook. Based on their 'Free Excerpt' writeup on the topic of 'Adapters' and their LoremWidget code (which I found while googling on the subject of examples/tutorials for widgets), they seem well-versed on the subjects...even the more esoteric ones. So, it was a no-brainer.

There are TONS of great open-source projects on 'GitHub.com'. To access those most easily, you simply need to create yourself an account on GitHub, install the recommended cmd-line 'git' client, and then do a 'clone' of an ENTIRE repository (e.g. their 'cw-omnibus' repository), and then just point Android-Studio IDE down into the resulting sub-tree to the individual project of interest, and then use the Android-Studio IDE's 'Import Project' dialog.

Note: There is a wonderful 4-part tutorial on YouTube, entitled 'git and GitHub' that got me started on the wonderful world of 'git'! If you're a 'true believer' in open-source (as I am), you will just love GitHub. [What's not to like about a website that offers FREE repository service to everyone who is willing to store their source-code in a public repository as open-source, and CHARGES a FEE only to those who want a private closed-source repository!!! ]

Android Studio caution: Steep Grade Ahead !?

In 2014, I found the NATIVE Android's learning-curve to be a bit steeper than I first envisioned. But, I shouldn't have been surprised, as my Java skills had been laying relatively dormant, since about the time that the Java-language introduced 'Generics'...back in...2004. Also, as expected, there are UI-classes to get your head around in Android. The Android details seemed to take awhile to get comfortable with.

Android Studio re-visited again (in 2018)

In early 2018, after reading of new dual-OS (Android and iOS) support from Google, discussing languages/frameworks such as 'Dart/Flutter' and 'Kotlin', I decided to take a peak again at the newest Android Studio (v3.0). I quickly gave up trying to learn new frameworks/languages, and focused back on the original Java-based approach. I discovered a number of new features in Android Studio that make it even harder to use/learn than back in Studio's version 1.0 days. My biggest complaint is their new approach to editing file(s). Now in V3, as you make changes to, say, a Java-source file, they are sillently making certain related auto-changes to other files, that if you then want to 'undo' your Java-code changes, they emit msg saying 'undo is not possible'. Further more, there is no longer any way to arrange that they'll tell/ask if you want to save changes when you close the file. There are numerous complains/pushback on this new 'feature'...here's an early one from back in Dec 2016: here's one such debate.

After some sustained reading of various new complaints and difficulties being posted at 'StackOverflow', I'm seriously starting to wonder just how many 'newbies' to Android Studio are getting frustrated and going with more straight-forward IDE's such as Eclipse, etc. (Stay tuned.)

For the longer term, I've ended up staying with the classic "Web-apps" approach, rather than continue to invest in the native Android-specific framework. So I built a web-server-side 'jar' that could collect on-air-Veetle-channel meta-data, and put it into an XML-file. I then wrote some generic HTML5 webcode to implement the client-side, by using the standard AJAX method of fetching that data to present 'schedule-data' for all the on-air Veetle channels (those that chose to publish a broadcast-schedule).

Android Scripting layer

Another more simplistic method for Android development is to use their so-called Android Scripting layer. But, after I read that it is considered "Alpha-level" of maturity, I decided to wait awhile longer before investing in that.




(Old - 2014) : Outline for understanding and learning PhoneGap / Apache Cordova



Workshop is approx 70% HTML5 and Javascript-coding practices vs only 30% PhoneGap specifics...PhoneGap itself is an easy-to-learn 'packager'. ]
[ This workshop is from 2013 and thus uses the older version v3.0 (vs the v4.0 avail now) ]

           Part 1 of of the PhoneGap-workshop highlights :
Note that PhoneGap uses std webpage technologies: Html, Css, Javascript, but emphasizes the efficiency of SPA (single page architecture).
Note that you can still be using other familiar skills and scripts (like jquery, MVC methodology and other fav-frameworks)!
Note the upfront mention of 'GitHub', which fits nicely with the ability to do remote/cloud-based builds for PhoneGap's platforms.
Note his mention of his sample of javascript for 'routing' (hash-tags appended to the URL) and see his TEMPLATES explanation.
[ Templates allow you to better isolate/modularize each 'view' as HTML-divs, with embedded {{placeholders}}, and its related Javascript. ]
One common style-usage for using templates is to put each template 'view' inside script-tagged sections.
[ He advocates use of a 'templating engine', such as 'Handlebars.js, 'Mustache.js', 'Underscore,js', or 'Dust.js' ]

           Part 2 of the PhoneGap-workshop highlights :
Pre-requites: Install 'git' and then install 'node.js' (YouTube has short how-to videos for these.)
Then install the PhoneGap "CLI" (or alternatively, the Cordova "CLI")
Concept: To build your app, you use the CLI, which can use the cloud to do each target-platform's build ! COOL !
Concept: To build locally, you need to have 2 Android-SDK things on your path: (i.e. 'tools' and 'platform-tools')
But, if either of those aren't setup, and if you've signed up (at "build.phonegap.com") for a free acct, it uses cloud for a build !
(For more than one FREE build, your app must be 'open source' (which just means 'in a github repository') ! Also COOL!
All your coding and building can be done in the cloud! [ So no specific IDEs nor SDKs are needed on your local machine! ]
As of 3.0, NO plugins are pre-installed in projects! So, you'll always want: 'device', 'console', and 'dialogs'. Add others as needed.
PhoneGap supplies approx 20 'core plugins', for interfacing to the sensors, hardware, and other 'services'. (@30 minute-mark)
E. G, there are plugins for: Camera, GeoLocation, etc, etc. (There also there are easily 50 plugins beyond 'core'.)
Consider using Adobe's nice simple open-source editor called 'Brackets'. (Sounds similar to my 'Scite' editor.)
Strongly consider using Adobe's open-source 'Topcoat', which is a thin UI-frame (its CSS - adds a nice orthogonal style to the app)

           Part 3 of the PhoneGap-workshop highlights : [ JS-topics ]
Structure your code, with an MV* model...MVC(model-view-controller) or MVDM(multi-view decision making)
His javascript coding examples are readable (when he moves focus in)...even better, the code should be on GitHub.
He also shows clean examples of using XMLHttpRequest (XHR) to load templates (HTML files) from server.
He discusses "async adapter and promise pattern" ((@16 mins into part 3...need to do some studying on this pattern.)
He explains and uses Require.js ...@23 min mark, which ensures that module dependency loading happens cleanly..
He discusses namespaces @25 min mark, and mentions the issue of nested names.
Find some books or tutorials on Javascript Patterns (and CSS Patterns?)
CommonJS vs NodeJS vs AMD, etc.
      [Hmm...'npm' is the package-mgr for Node.js, so maybe we should learn some NodeJS!?]
He prefers Backbone.js over Angular.js and Knockout.js and Ember.js...he considers Backbone.js to be the "least-opinionated".
Data Access technique/pattern: @1:01 in part 3, he talks about abstracting the data-interface, by using 'Pluggable Data Adapters'.
Here he talks alot about keeping the app so it ALSO still runs in a std browser. e.g. using mouse and keyboard. so abstract 'Touch' also.
Issue: Click-handler takes 300ms (on iOS), we use Touch-handler, which is 2ms. Ah, but now it won't run in std browser. Solution: "Fastclick"!
Another approach, rather than using Fastclick, is to use Hammer.js (http://hammerjs.github.io/)
Re-watch the end (there are some CSS and HTML performance optimizations that I don't really yet understand).

Post-workshop ideas, relating to the workshop
(1) How to render some HTML, before using JS to populate it with data: I think that "(document).ready" function is a way to delay stuff. Here's an example, complete with a jQuery-based JSFiddle implementation:
(2) The "critical render path"...an article explaining it, and also providing an 'efficiency evaluator' to point your web pages to !
(3) The 'weird' JS-coding I'm seeing (e.g. with the last line of " })(); " are because they result from defining a name-less function inside another function, because JS has not explicit way to distinguis a 'private' vs 'static' vs 'public' variables. These are called 'closures'.
(4) Comment seen at StackOverlow (5-years-old now):
If you are a GWT programmer(like me), you may want to check out GWT Mobile, an open source project for creating mobile web apps with GWT.
    It includes a PhoneGap GWT wrapper that enables the use of PhoneGap in GWT.

Here is nice overview of concepts and API for PhoneGap/Cordova

This W3C document on "Packaged Web Apps" generically describes the root concepts of PhoneGap/Cordova

Other mobile-device Frameworks

In about 2013, I did a careful re-survey of the most favored frameworks for tablets/smartphones. The rest of this page, summarizes my findings. [Hope they're helpful to you.]

My first exposure was to use the jQuery-mobile framework, and build a simple series a pages. (No javascript was needed for this effort. See my 'Musicians' pages here at this site.)

My second exposure was to use my Java language background, and build a simple native app for Android, using Google's free 'Android Studio'. (It was a handy Veetle movie-broadcaster's channel-status tool. Note: Veetle.com went out of business in July of 2016.)

In 2015, I played with (e.g. done a few tutorials, and some google fact-finding) some of the various frameworks, such as 'Knockout-JS', 'Angular-JS', and 'PhoneGap', etc.

It then occurred to me, that I really needed to decide just how comfortable I am, relatively, between using Java vs Javascript. For me, Java keeps coming up as my personal preference. So, with that in mind, I've included below, the frameworks that I examined.

Java-based frameworks:

This is free, from Google. This is now my preferred choice, as it is Java-based. (My Java skills are definitely better than my Javascript skills.) Yet PhoneGap's ability to package apps for multiple tablet OSes (Android and iOS, in that order, are my target-platforms.)
Lastly, the kicker is that this framework utilizes 'Maven' for it's build-system, and that's also my current favorite. Go for it. This appears to be free. [Oracle owns/pushes 'NetBeans' as their IDE.] Tabris is relatively new. Client-side costs money (client is used to generate the native APK, etc)

'mgwt' (think m-GWT)

From the mgwt wiki: Check out Daniel Kurka's blog (he's from Germany) : Also there are a few M-GWT-related videos (on YouTube): The basics of GWT's pattern MVP (Model-View-Presenter) is in the GWT docs.

Note: Other of my 'Dharma-team' members advocate webapps built with a framework called 'PhoneGap'. PhoneGap is also known now as Apache Cordova.

My newest book for learning Android development, published by "CommonsWare" (see previous section) spends the first 75% or more of the book, teaching 'native' Android development, but then it eventually does discuss and explain frameworks such as "HTML-5" and "PhoneGap", and points out that if you use those frameworks, you could return to that original slogan of Java: "write once, run anywhere". Because the HTML-5 and PhoneGap/Cordova and mgwt frameworks produce deployables that will run on iOS as well as Android (and on some other platforms as well)!

About a year ago, I learned of the intersection of GWT and PhoneGap. There is a JAR called "gwt-phonegap.jar". I initially tried to go build a simple such app to see how it all works, but I had technical problems getting it installed and working, so I put a bookmark in that effort.

GWT-PhoneGap

Note (in the Getting Started Guide) references to using Maven, and note it is tested only for Android-OS and iOS. That would be very cool, because using the PhoneGap framework allows one to multiple tablet platforms, from one code-base.

Javascript-based frameworks

AngularJS - this new JS-front-end framework is 'highly-recommended'

Ken started a new job doing AngularJS work, and he suggests the following learning-path:
[ kayaker paddling ]