Android – Adding native functionality to hybrid application with Apache Cordova plugin

Today I would like to share with you about how to adding native functionality to hybrid application with Apache Cordova Plugin in simple way. Someone ask me how to do it. Is it impossible? Nope, it’s possible. You can add native functionality to hybrid app can be done using correct method.

There are two types of platform that I want to teach you today, iOS and android. You need to use cordova.exec API to communicate between native functionality and hybrid application.

phonegap (cordova) + android

phonegap (cordova) + android

Android

Firstly you need to declare your custom plugin in config.xml. You can found this file in res > xml folder.

<feature name="CustomPlugin">
      <param name="android-package" value="com.Phonegap.CustomPlugin" />
</feature>

Then you need to implement plugin by using Java- code

public class CustomPlugin extends CordovaPlugin {

    @Override
    public boolean execute(String action, JSONArray args, CallbackContext callbackContext)
            throws JSONException {

        if (action.equals("sayHello")){
            try {
                String responseText = "Hello world, " + args.getString(0);
                callbackContext.success(responseText);
            } catch (JSONException e){
                callbackContext.error("Failed to parse parameters");
            }
            return true;
        }

        return false;
    }
}

Finally we calling a plugin from javascript

function initial(){
    var name = $("#NameInput").val();
    cordova.exec(sayHelloSuccess, sayHelloFailure, "CustomPlugin", "sayHello", [name]);
}

function sayHelloSuccess(data){
    alert("OK: " + data);
}

function sayHelloFailure(data){
    alert("FAIL: " + data);
}

If you want to know more details about this tutorial, you can download the pdf file here.

http://public.dhe.ibm.com/software/mobile-solutions/worklight/docs/v610/06_05_Android_-_Adding_native_functionality_to_hybrid_application_with_Apache_Cordova_plugin.pdf

Next tutorial will be IOS part. I hope you don’t hesitate to contact me if you got any issue regarding to this tutorial. Enjoy !

8 great tools for hybrid mobile app development

Sometimes hybrid mobile app can be done but without correct tools, the app cant be done on time. It depends how developer choose what type of development tools to develop the mobile app. Mostly there are free and some tools need to be pay in other to use them. There are a several of cons and pros either for free or paid.For example, if the tool is free or in other word is for community edition, the developer wont get any support from the company who create the tools compare to paid tools, the company will give support if occur any issues.

Today I would like to share with you 8 great hybrid mobile app development tools.

Eclipse Juno R2

eclipse juno r2

http://www.eclipse.org

Dreamweaver CS6.5

dreamweaver cs6

http://www.adobe.com

Xcode5

xcode5

https://developer.apple.com

Visual Studio 2012

visual studio 2012

http://www.visualstudio.com/

Chrome

chrome

https://www.google.com

Ripple

ripple

ripple

Slimtext

slimtext

http://slimtext.org/

Github

github

https://github.com/

4 great hybrid mobile app references

What is hybrid mobile app? Referring to  Nielsan Norman Group, “hybrid mobile app is part native apps, part web apps. Like native apps, they live in an app store and can take advantage of the many device features available. Like web apps, they rely on HTML being rendered in a browser, with the caveat that the browser is embedded within the app”.

Many amateur programmers didn’t know how to develop a simple hybrid mobile app. It is because they didn’t know where to start, how to develop with correct tools and techniques and when they can actually start build the hybrid mobile app. Sometimes the hybrid mobile app can be done but without correct tools, it can’t be done on time.

Nowadays the mobile is very important in daily life. Mobile is primary. According to Gartner, 91% of mobile users keep their device within arm’s reach 100% of the time. They mostly prefer using mobile rather than laptop or PC to surf internet. It because it so much easier to carry out everywhere.

Today I would like to share with you 10 great hybrid mobile app references.

Jquery

jquery

http://jquery.com

Jquery Mobile

jquery mobile

http://jquerymobile.com

Phonegap

phonegap

http://phonegap.com

Backbone.js

http://backbonetutorials.com