Code Example‎ > ‎


Create a new project

Choose File >>New>>Project under eclipse menu.
Then from the New Project Dialog, Select Droidget Wizard>>Project
Fill necessary fields including project name..etc.. and Click Finish
Project with the given name will appear in the Eclipse project explorer.

Edit config.xml

<?xml version="1.0" encoding="UTF-8"?>
<widget id="AlertSample_1279579008553" version="1.0" width="300" height="150">
    <content src="index.html" type="text/html"/>
    <description>The sample of Alert</description>
    <author url="">GClue</author>
    <icon src="icon.png"/>

Create a Javascript file

Under src folder, create another folder called ‘js’ and create a file called scripts.js under ‘js’ folder

  • Right click (Command click on Mac) on the Project name
  • Choose File >> New >> Folder and name it as js
  • Right click (Command click on Mac) on js foder , then File >> New >> File  and name it as scripts.js
// show alert
function showAlert(){ 
    alert("The message of Alert");

Edit index.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="Content-Style-Type" content="text/css" />
    <meta http-equiv="Content-Script-Type" content="text/javascript" />
    <title>JSON Sample</title>
    <script type="text/javascript" src="js/script.js"></script>
    <input type="button" id="formBtn" value="Click Here" onclick="showAlert()"/>

Deploy the Widget

Now save and deploy the project
  • From the eclipse menu select Droidget --> packaging
  • Then Droidget-->install packaging
  • upload the Widget to web server and update the download.html file as follows. Then access the download.html from the smart phone and install the widget from URI.
    <a href="droidget://">AlertSample</a><br>