Chapter 5. Inter-workings of the JavaScript and Java Layers

Now that we have looked at each individual piece, let’s put it all together and look at the end-to-end architecture of a hybrid application.

Architecture of a Hybrid Application

Hybrid applications are special, bringing together best of both worlds to an extent. Architecturally, an hybrid application would look like Figure 5-1.

A sufficiently complex hybrid application would typically contain most of the components identified in Figure 5-1, although not necessarily. Let’s quickly go over these components before we delve into more details.

A hybrid application is a primarily a web app with access to platform capabilities through an additional set of user defined APIs. This web application requires a WebView to render content and host the business logic.
View, model, and controller
Since the application is primarily written in JavaScript, depending upon the JavaScript library you use, you will have some form of implementation of model, view, and controller components.
JS-Java Bridge
It is the glue layer that allows the native and web environments to interact with each other. The bridge should allow for execution of synchronous and asynchronous APIs. As was discussed in the previous chapters, this layer is one of the most crucial layers in a hybrid application for several reasons, including performance, ease of use, and security.

Figure 5-1. Hybrid application architecture

Java plug-ins
A Java plug-in is the user ...

Get Building Hybrid Android Apps with Java and JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.