Skip to content Skip to sidebar Skip to footer

Phonegap Webview - Show Contacts List For Android Only

I have setup and installed Phonegap on my Eclipse environment together with Android SDKs. Everything seems to be working fine except when I install additional phonegap plugin [http

Solution 1:

The files below should make it work. BTW, I'm not sure what's in your calllog.js, but there definitely needs to be a ContactView.js in index.html. See the following files and screenshot of the full app running:

index.html

<!DOCTYPE HTML><html><head><metaname="viewport"content="width=320; user-scalable=no" /><metahttp-equiv="Content-type"content="text/html; charset=utf-8"><title>PhoneGap Demo With JQuery Mobile</title><linkrel="stylesheet"href="jquery.mobile/jquery.mobile-1.0.css"type="text/css"/><linkrel="stylesheet"href="pgandjqm-style-override.css"type="text/css"/><scripttype="text/javascript"charset="utf-8"src="jquery.mobile/jquery-1.6.4.min"></script><scripttype="text/javascript"charset="utf-8"src="phonegap-1.3.0.js"></script><scripttype="text/javascript"charset="utf-8"src="jquery.mobile/jquery.mobile-1.0.js"></script><scripttype="text/javascript"charset="utf-8"src="main.js"></script><scripttype="text/javascript"charset="utf-8"src="ContactView.js"></script><scripttype="text/javascript"charset="utf-8">var successCallBack = function(args) {
        alert (JSON.stringify(args));
        };
      var failCallBack = function(args) {
        alert (JSON.stringify(args));
        };
      </script></head><bodyonload="init();"><divdata-role="page"data-theme="b"><divdata-role="header"><h1>Welcome to Stellar</h1></div><divdata-role="content"><ahref="tel:411"data-role="button">Call 411</a><divdata-role="button"onclick="window.plugins.ContactView.show('all', successCallBack, failCallBack);">Beep</div><divdata-role="button"onclick="beep();">Beep</div><divid="viewport"class="viewport"style="display:none;"><imgstyle="width:60px;height:60px"id="test_img"src="" /></div></div><!-- end jqm content --><divdata-role="footer"><h1>Thanks for being around</h1></div></body></html>

ContactView.js

varContactView = function() {};

ContactView.prototype.show = function(cmd, successCallback, failCallback) {

    functionsuccess(args) {
        successCallback(args);
    }

    functionfail(args) {
        failCallback(args);
    }

    returnPhoneGap.exec(function(args) {
        success(args);
    }, function(args) {
        fail(args);
    }, 'ContactView', '', []);
};

/**
 * Load ChildBrowser
 */PhoneGap.addConstructor(function() {
    PhoneGap.addPlugin("ContactView", newContactView());
});

Also, res/xml/plugins.xml needs the following line added:

<pluginname="ContactView"value="com.rearden.ContactView"/>

Next is the screenshot showing the directory structure, changed files and running app:

Screen shot of running app

Post a Comment for "Phonegap Webview - Show Contacts List For Android Only"