0

Trying to learn android app development. I need a general idea. I read that apps can be built with HTML5. But I know that HTML5 will allow only native apps, by which I mean, no server, no database nothing. Thats what I guess.
Like in web development we have PHP as server side language which handles all the server side operations, what is the server side language in android? Lets take example of instagram (I am not going to build something like that but just want to get the idea). It stores photos, users can like, share their personal info, store, delete etc. Can such app be made with HTML5? Or Java, Python is necessary for such heavy and complex application? If anyone could provide a proper info on android app development both native and web, I would be thankful.

asked Apr 6, 2015 at 15:17

1 Answer 1

2

HTML5 can be used to replace the UI of the application - rather than using layouts and android components (LinearLayout, RelativeLayout - ListView, RecyclerView - TextView, Button, ImageView...) you'd use HTML/CSS/JS to display your UI in a web view. You can also specify click events in rendered HTML inside the webview, for which you could use @JavascriptInterface annotated methods in Java that would communicate to Android (reliable ONLY from 3.0 and above! It's bugged in 2.3!!!), so that you could execute logic on the Java level.

If you need to communicate with a server, then if you use HTTP (or maybe even HTTPS up to a certain point - client certificates are not supported), then you can even use jQuery $.ajax() requests.

Although there are a whole new level of problems that arise in the process. Error handling can become chaotic, CSS can be inconsistent among Android 4.3 and below versus Android 4.4 and above (unless you use the Crosswalk Project 1 2 which is 4.0+ only).

The biggest hassle of course is communicating from Java to Javascript, and from Javascript to Java. Please note that the @JavascriptInterface calls are done by the render thread of the WebView itself.

For that, I used this

(function(root) {
 root.bridge = (function() {
 var handlers = {};
 return {
 init: function () {
 },
 getHandlers : function() {
 return handlers;
 },
 callHandler : function(name, param) {
 if(param !== null && param !== undefined) {
 Android[name](param);
 } else {
 Android[name]();
 }
 },
 registerHandler : function(name, method) {
 if(handlers === undefined) {
 handlers = {};
 }
 if(handlers[name] === undefined) {
 handlers[name] = method;
 }
 }
 };
 }());
})(this);

As I explained here: https://stackoverflow.com/a/27426896/2413303

The server side is completely independent from the Android client. It can be stackless Python to PHP, Ruby on Rails or Java EE / Spring Framework, the Android client doesn't care - as long as you use REST API rather than web services. SOAP is hell on Android.

answered Apr 6, 2015 at 15:29
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for the reply. I like HTML5 coz it is cross-platform compatible. If I make and app in android studio, i will have to make app for IOS in XCODE (Thats what some people told me). SO instead of making 2 versions make it with HTML5 which is cross platform. Now, do you mean complex apps can be built with HTML5 with Java etc in the backend?
Technically, I am working on one at work. But I kid you not: the CSS inconsistencies take up way more time than what you gain, native apps tend to be quicker, and using jQuery Mobile instead of the Ionic Framework was one of the worst decisions we made. jQM is an unstable mess. Also, you must never use more than one local HTML file - use a framework of some kind (AngularJS, Ionic, or maybe even jQM if you hate yourself) because emptying the DOM and reloading the DOM takes too much time and causes really bad flickers. For backend, we used Spring Framework. Spring Boot is amazing.
Honestly, hybrid apps are worth it only if you can get away with a larger APK, you are 4.0+ or above, and you use Crosswalk instead of the native webview because there are a LOT of glitches in the 4.3- webview. Otherwise, instead of using Android-specific things, you'll be spending your time fixing the weirdest of bugs. For example, the Javascript Interface not reloading the second time you load the app. See for yourself: stackoverflow.com/questions/18654009/…
The weirdest thing is that we needed to make a timeline-like thing, and it was very slow. So I had to use a library called iScroll 5 to make it not slow. Hybrid apps have a lot of surprises on the go.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.