Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

199 lines (179 sloc) 8.258 kb
<!DOCTYPE html>
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
--><html lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width">
<meta name="generator" content="joDoc">
<title>Apache Cordova API Documentation</title>
<link rel="stylesheet" type="text/css" href="index.css">
<link rel="stylesheet" type="text/css" href="mobile.css" media="only screen and (max-device-width: 1024px)">
<link rel="stylesheet" type="text/css" href="prettify/prettify.css">
<div id="header">
<h1><a href="index.html">Apache <strong>Cordova</strong> Documentation</a></h1>
<select><optgroup label="English" value="en">
<option value="edge">edge</option>
<option value="2.1.0rc2">2.1.0rc2</option>
<option value="2.1.0rc1">2.1.0rc1</option>
<option selected value="2.1.0">2.1.0</option>
<option value="2.0.0rc1">2.0.0rc1</option>
<option value="2.0.0">2.0.0</option>
<option value="1.9.0rc1">1.9.0rc1</option>
<option value="1.9.0">1.9.0</option>
<option value="1.8.1">1.8.1</option>
<option value="1.8.0rc1">1.8.0rc1</option>
<option value="1.8.0">1.8.0</option>
<option value="1.7.0rc1">1.7.0rc1</option>
<option value="1.7.0">1.7.0</option>
<option value="1.6.1">1.6.1</option>
<option value="1.6.0rc1">1.6.0rc1</option>
<option value="1.6.0">1.6.0</option>
<option value="1.5.0rc1">1.5.0rc1</option>
<option value="1.5.0">1.5.0</option>
<option value="1.4.1">1.4.1</option>
<option value="1.4.0rc1">1.4.0rc1</option>
<option value="1.4.0">1.4.0</option>
<option value="1.3.0">1.3.0</option>
<option value="1.2.0">1.2.0</option>
<option value="1.1.0">1.1.0</option>
<option value="1.0.0rc3">1.0.0rc3</option>
<option value="1.0.0rc2">1.0.0rc2</option>
<option value="1.0.0rc1">1.0.0rc1</option>
<option value="1.0.0">1.0.0</option>
<option value="0.9.6">0.9.6</option>
<option value=""></option>
<option value="0.9.5">0.9.5</option>
<option value="0.9.4">0.9.4</option>
<option value="0.9.3">0.9.3</option>
<option value="0.9.2">0.9.2</option>
<optgroup label="Español" value="es"><option value="1.0.0">1.0.0</option></optgroup>
<optgroup label="Français" value="fr">
<option value="1.3.0">1.3.0</option>
<option value="1.2.0">1.2.0</option>
<option value="1.1.0">1.1.0</option>
<optgroup label="Japanese" value="jp">
<option value="2.0.0">2.0.0</option>
<option value="1.9.0">1.9.0</option>
<option value="1.8.1">1.8.1</option>
<option value="1.7.0">1.7.0</option>
<option value="0.9.5">0.9.5</option>
<optgroup label="Korean" value="kr"><option value="2.0.0">2.0.0</option></optgroup></select></small>
<div id="subheader">
<h1>Developing a Plugin on Bada</h1>
<div id="sidebar">
<div class="vertical_divider"></div>
<h1>API Reference</h1>
<li><a href="">Accelerometer</a></li>
<li><a href="">Camera</a></li>
<li><a href="">Capture</a></li>
<li><a href="">Compass</a></li>
<li><a href="">Connection</a></li>
<li><a href="">Contacts</a></li>
<li><a href="">Device</a></li>
<li><a href="">Events</a></li>
<li><a href="">File</a></li>
<li><a href="">Geolocation</a></li>
<li><a href="">Media</a></li>
<li><a href="">Notification</a></li>
<li><a href="">Storage</a></li>
<li><a href="">Getting Started Guides</a></li>
<li><a href="">Command-Line Usage</a></li>
<li><a href="">Upgrading Guides</a></li>
<li><a href="">Plugin Development Guide</a></li>
<li><a href="">Domain Whitelist Guide</a></li>
<li><a href="">Embedding WebView</a></li>
<li><a href="_index.html">Keyword Index</a></li>
<div id="scrollable">
<div id="content">
<h1><a name="Developing%20a%20Plugin%20on%20Bada">Developing a Plugin on Bada</a></h1>
<p>Plugins are only supported on Bada 2.0 and above. Bada 1.2 does not support plugins.</p>
<p>The Bada implementation is a full javascript implementation. Therefore, adding a custom plugin involves updating CordovaJS with your plugin code. Follow these steps to add a simple <em>Hello World</em> plugin:</p>
<p>Clone the CordovaJS repository</p>
<pre class="prettyprint"><code>git clone
<p>Create a new javascript file under <strong>lib/bada/plugin/bada/</strong> and name it <em>HelloWorld.js</em>. Add the following content:</p>
<pre class="prettyprint"><code>function HelloWorld() {
HelloWorld.prototype.printHello = function(success, fail, arg) {
alert(Osp.Core.StringHelper('Hello %1', arg[0]));
module.exports = new HelloWorld();
<p>Add a link to your newly created plugin in <strong>lib/bada/platform.js</strong> under the objects property:</p>
<pre class="prettyprint"><code>objects: {
HelloWorld: {
<p>Update the plugin list under <strong>lib/bada/exec.js</strong> to include your plugin</p>
<pre class="prettyprint"><code>var plugins = {
"HelloWorld": require('cordova/plugin/bada/HelloWorld')
<p>Now you can write your user-facing javascript however you like but remember that in order for your plugin to execute you need to call the following method</p>
<pre class="prettyprint"><code>exec(succes, fail, 'HelloWorld', 'printHello', ['Jackson!']);
<p>success is the success callback that gets executed when the plugin succeeds
fail is the failure callback that gets executed if the plugin fails
'HelloWorld' is the name of your plugin
'printHello' is your plugin action
Finally, the last argument is your plugin parameters (if any).</p>
<p>Run the following command to generate the new common javascript (make sure you have the jake npm module installed)</p>
<pre class="prettyprint"><code>jake
<li><p>Copy the newly generated javascript under <strong>pkg/cordova.bada.js</strong> to your Bada project under <strong>Res/js</strong></p></li>
<li><p>That is it! You can now add new Bada plugins and implement the many features that are not currently supported by Cordova Bada.</p></li>
<!-- Functionality and Syntax Highlighting -->
<script type="text/javascript" src="index.js"></script><script type="text/javascript" src="prettify/prettify.js"></script>
Jump to Line
Something went wrong with that request. Please try again.