Writing Android apps in Javascript

Another way to develop apps for Android is to write apps in the Javascript program scripting language (note – Javascript is not related to Java, in spite of the similar name). By using a special platform called Cordova, it is possible to package Javascript programs into a self contained Android .apk file that runs on the Android OS.

Even better – it is possible to package your Javascript app, using Cordova, into forms that run on iOS (iPhones and iPad) and Windows Phone too!

Javascript was developed way back in 1995 as a web programming language that runs inside an Internet browser (Netscape back then, but today in Firefox, Chrome, Opera and Internet Edge). As such, Javascript has become an important programming language for developing “web apps” that are accessible online and which run inside the browser.

Since mobile devices have browsers – and apps can launch a web page (even in App Inventor apps) – you can see how Javascript might be used to write an app that can be run on a mobile device. In fact, if you access a web page online from your phone, you can and are running Javascript apps from remote web sites.

The difference is that we can also package a Javascript app, wrapping it up inside a regular .apk file. This then becomes an installable app that can run directly on an Android phone or tablet, without the need to be online and connected to a web site.

Unfortunately, I do not have time to go into the details of using Javascript to write Android apps, at least for now. But I can provide some pointers on where you can get started.

Step 1

Learn Javascript. You can use online tutorials, or printed or e-books on Javascript. As you learn, you can write example code that runs in your browser. No special hardware required. A good resource is the Mozilla Developer Network at http://developer.mozilla.org

Once there, click on the Javascript link and follow that to documentation and tutorials.

Step 2

Install the Intel XDK. The XDK is an excellent integrated development system for writing apps in Javascript, testing and ultimately building them for running on Android, iOS and Windows phone. The XDK is a free download available from Intel.

Step 3

Begin to learn about Javascript support systems like Cordova (also known by its prior name “PhoneGap”) and JQuery Mobile. These provide the equivalent of libraries of additional functions that you can use in your program, especially to interface with the phone’s hardware and to provided enhanced user interface components.

You do not need to know much about PhoneGap, or a library like JQuery Mobile, if using the Intel XDK. Instead, just draw out your application user interface and write event handlers to process user input.

If you have mastered App Inventor and are looking for future growth and learning opportunities, Javascript, with the Intel XDK, is a logical next step, albeit, a potentially large step. However, this path can greatly leverage what you have learned with App Inventor. For example, a “click” event in App Inventor becomes an “onclick()” event in Javascript. There are many analogies.

Another direction to consider is learning Java and the Android Studio. But with the warning that this is a steeper learning curve – there is much to cover!

3 thoughts on “Writing Android apps in Javascript”

Comments are closed.