OMS

 

一、What is OMS

Introduction of OMS Platform

OMS 平台介绍

The OMS(Open Mobile System) is an open terminal software platform for mobile internet. It is designed for mobile terminals and is a complete solution which includes a linux operating system, a dalvik virtual machine, a web browser, middlewares and key applications. OMS derives from Android platform. Including Android components, OMS also integrates a great many enhanced middlewares, applications and China Mobile Value-added services. For example, OMS gives developers an optimized local search engine and APIs, which could be used to integrate local search functionality into their own applications. At the same time, OMS implements applications of China Mobile Value-added services, such as PushEmail, MobileMusic, DCD, Fetion and so on, to give exclusive experiences for OMS users and to enable developers exploiting more fabulous features. Moreover, Widget Application, which is not supported by Android, has been provided by OMS. Developers can create various applications and colorful presentations using Widget APIs.

OMS(Open Mobile System)是一个开放的移动互联终端软件平台。它为移动终端设计;它是一个完全的解决方案,包括一个LINUX操作系统,一个DALVIK虚拟机(GOOGLE开发的一个JAVA虚拟机),一个web浏览器,中间件和关键应用。OMS起源于Android平台,包括了Android组件,OMS集成了许多增强的中间件,应用程序和中国移动增值业务。例如,OMS提供开发者一个优化的本地搜索引擎和API,这些可以被应用到集成本地的搜索功能到他们的应用程序中,同时,OMS实现了系列中国移动增值 ,包括PUSHMAIL,无线音乐,DCDDynamic Content Delivery移动快讯),飞信等等,为OMS用户提供一个独特的体验,允许开发者开发更多漂亮美好的特色程序。此外,Widget应用程序,移动有OMS提供,而不是由Android支持。开发者使用Widget API可以创造各种各样的应用,色彩丰富的外观。

All in all, in order to provide friendly human interface and prominent user experiences for mobile terminal users, OMS platform is built to be open.

总之,为了提供给移动终端用户友好的人机界面和卓越的用户体验,OMS平台设计成一个开放的平台。

OMS SDK is an all-in-one SDK, and it supports two kinds of application development:

OMS SDK是一个一体化的SDK,它支持两类应用开发:

·         OMS Application OMS应用程序

·         Widget Application Widget应用程序

OMS Application OMS应用程序

OMS application is java-based application, and is similar to Android application. Whereas, comparing with Android, OMS provides plenty of OMS APIs which OMS platform featured to differentiate and extend the functionalities from Android.

OMS应用程序是基于JAVA的应用程序,与Android应用程序相似。但是,与Android相比,OMS提供许多OMS APIOMS平台突出与Android不同,扩展更多的功能。

Since OMS is compatible with Android, you can use both OMS API and Android API to develop OMS applications. Any applications created by Android API can run correctly in OMS phones. Nevertheless, your applications can not run in Android phones when using OMS extended API, which is highly featured by OMS platform and is crucially required at runtime.

由于OMSAndroid兼容,你可以使用OMS APIAndroid API开发OMS应用程序。任何使用Android API创建的应用程序可以正常运行在OMS手机上,然而,你的应用程序如果使用了OMS扩展API不能在Android手机上运行,OMS extended API具备OMS平台高级特征和关键必须的运行库。

To know more about OMS API, please refer to OMS API Reference

想了解更多关于OMS API,请查阅OMS API Reference

In addition, you can use Android Develeopment Tools (ADT) to create OMS applications in Eclipse IDE. The ADT plugin includes a variety of powerful extensions that make creating, editing, running and debugging OMS applications faster and easier.

另外,你可以在Eclipse IDE里使用Android开发工具(ADT)创建OMS应用程序。ADT插件包括多种强大的扩展,使得创建,编辑,运行和调试OMS应用程序更快更方便。

Widget Application

Widget应用程序

Besides java-based applications, OMS also supports widget applications (xHTML, CSS, JavaScript etc.) development. Widget application is the highlight of OMS since Android has not supported widget application development, yet.

Widget应用程序居于JAVA的应用程序,OMS也支持Widget应用程序(Xhtml,css,javascript等等)开发。Widget应用程序OMS的高级应用,Android还没有提供Widget应用程序开发。

In OMS, widget application follows JIL (Joint Innovation Lab) Widget Specification. To know more about Widget, please refer to Widget Introduction.

OMSWidget应用程序遵从JIL(Joint Innovation Lab) Widget规范。想了解更多关于Widget,请查阅Widget介绍。

If you expect using the Eclipse IDE as your environment for developing Widget applications, you can install a custom plugin called Widget Development Tools (WDT), which adds integrated support for Widget projects. The WDT plugin includes a variety of powerful extensions that make creating, editing, building, running and debugging Widget applications faster and easier.

如果你想使用Eclipse IDE作为你开发Widget应用程序的开发环境,你可以安装一个Widget开发工具的插件,它加入了Widget工程中和支持。WDT插件包括多种强大的扩展,使得创建,编辑,构建,运行和调试Widget应用程序更加快捷方便。

is the logo of OMS.

OMSLogo

 

二、Getting Started

Installing the OMS SDK

安装OMS SDK

This page describes how to install the OMS SDK and set up your development environment. If you haven't downloaded the SDK yet, you can use the link below to get started. Then read the rest of this document to learn how to install, configure, and use the SDK.

这个页面介绍怎样安装OMS SDK和设置你的安装环境。如果你还没有下载SDK,你可以通过下面的链接开始下载。然后通过阅读文档的剩下部分学习如何安装,配置和使用SDK

Download the SDK

System and Software Requirements

系统和软件要求

To develop OMS applications and Widget applications using the code and tools in the OMS SDK, you need a suitable development computer and development environment, as described below.

使用OMS SDK里面的代码和工具开发OMS应用程序和Widget应用程序,你需要一个适合的开发电脑和开发环境,如下面所示:

Supported Operating Systems:

支持的操作系统

·         Windows XP or Vista

·         Linux (tested on Linux Ubuntu 8.04)

Supported Development Environments:

支持的开发环境

·                     Eclipse IDE

o                    Eclipse 3.4.2 (Ganymede)

§                     Eclipse JDT plugin (included in most Eclipse IDE packages)

§                     WST 3.0.4

§                     EMF 2.4.2

§                     GEF 3.4.2

o                    JDK 5 or JDK 6 (JRE alone is not sufficient)

o                    Android Development Tools plugin

o                    Widget Development Tools plugin

o                    Not compatible with Gnu Compiler for Java (gcj)

Note: If JDK is already installed on your development computer, please take a moment to make sure that it meets the version requirements listed above.

注意:如果JDK已经安装在你的开发电脑中,请花点时间确认是否与上面列表所要求的版本一致。

Installing and Configuring the SDK

安装和配置SDK

After downloading the SDK, unpack the .zip archive to a suitable location on your machine. By default, the SDK files are unpacked into a directory named oms-sdk_<platform>-<release>. The directory contains the subdirectories tools/, samples/, and others.

下载完SDK后,加压.ZIP文档到你的计算机一个合适地方。缺省情况,SDK文件被解压到一个叫OMS-SDK_<平台>-<版本>的目录。这个目录包括tools/,samples/,和其他子目录。

Make a note of the name and location of the unpacked SDK directory on your system — you will need to refer to the SDK directory later, when setting up the ADT plugin, WDT plugin or using SDK tools.

记录下你电脑中解压缩SDK目录的路径和名字,当你设置ADT插件,WDT插件和使用SDK工具的时候,你需要参考SDK目录。

Optionally, you can add the path to the SDK tools directory to your path. As mentioned above, the tools/ directory is located in the SDK directory.

特别的,你可以把SDK工具的目录路径添加到你的路径中。正如上述所说,工具和目录指向SDK的安装目录。

·                     On Linux, edit your ~/.bash_profile or ~/.bashrc file. Look for a line that sets the PATH environment variable and add the full path to the tools/ directory to it. If you don't see a line setting the path, you can add one:

o                                            export PATH=${PATH}:<your_sdk_dir>/tools

LINUX系统中,编辑你的~/.bash_profile ~/.bashrc文件。查找环境变量中设置PATH的行,添加一个完整的工具/目录的路径。如果你没有看到设置PATH的行,你可以自行添加一个:

o                                            export PATH=${PATH}:<your_sdk_dir>/tools

 

·                     On Windows, right click on My Computer, and select Properties. Under the Advanced tab, hit the Environment Variables button, and in the dialog that comes up, double-click on Path under System Variables. Add the full path to the tools/ directory to the path.

WINDOWS系统中,右键点击我的电脑,选择属性菜单项。在高级选项页,点击环境变量按钮,在弹出的对话框中,双击系统变量的PATH列表项。添加一个完整的工具/目录的路径到PATH变量中。

Adding tools to your path lets you run the command line tools without needing to supply the full path to the tools directory. Note that, if you update your SDK, you should remember to update your PATH settings to point to the new location, if different.

添加TOOLS到你的路径,让你不用提供完整的工具目录就可以运行命令行工具。

Adding OMS User Library to Build Path in Eclipse IDE

添加OMS用户库到Eclipse IDE的构建路径

In order to use OMS APIs, we need add OMS User Library (oms.jar in the root folder of OMS SDK) to build path. The adding steps are listed as follows:

为了使用OMS APIs,我们需要添加OMS用户库(OMS SDK目录下的oms.jar)到构建路径。下面是添加的步骤:

1.                Select Window > Preferences... to open the Preferences panel.

选择Window > Preferences...打开参数控制面板。

2.                Select Java > Build Path > User Libraries from the left panel.

选择左侧列表中Java > Build Path > User Libraries

3.                In the User Libraries panel, click New to open 'New User Libraries' dialog and input OMS, and press OK.

在用户库控制面板,点击NEW 打开一个'New User Libraries'对话框和输入OMS,然后按下OK

4.                Click Add JARs to select oms.jar in OMS SDK root folder, and OK. Now the OMS User Library has been added to the build path in Eclipse IDE. When a new OMS project is created, you also need add the OMS User Library to the build path of the created project in order to use OMS APIs.

点击Add JARs,选择OMS SDK目录下的oms.jar,然后按下OK。现在OMS用户库已经添加到ECLIPSE IDE的构建路径中。

 

Installing the Eclipse Plugin (ADT)

安装Eclipse插件(ADT

If you will be using the Eclipse IDE as your environment for developing widget applications, you can install a custom plugin called Android Development Tools (ADT), which adds integrated support for widget projects and tools. The WDT(应该是ADT plugin includes a variety of powerful extensions that make creating, editing, running and debugging widget applications faster and easier.

如果你使用ECLIPSE IDE作为你开发Widget应用程序的环境,你可以安装一个叫做Android开发工具的插件,它加入了Widget项目和工具的整合支持。ADT插件包含了各种强大的扩展,让创建,编辑,运行和调试Widget应用程序更加快捷和方便。

Download the ADT 0.8.0 zip file (do not unpack it). The ADT zip is also available in the SDK (SDK folder/tools/ADT-0.8.0.zip).

下载ADT 0.8.0 ZIP文件(不要解压缩它)。ADT zip

For Eclipse 3.4 (Ganymede)

  1. Start Eclipse, then select Help > Software Updates....

启动Eclipse,然后选择Help > Software Updates....

  1. In the dialog that appears, click the Available Software tab.

在出现的对话框中,点击Available Software选项页。

  1. Click Add Site..., then Archive...

点击Add Site...,然后点击Archive...

  1. Browse and select the downloaded the zip file.

浏览和选择下载的zip文件。

  1. Back in the Available Software view, you should see the plugin. Select the checkbox next to Android Development Tools and click Install...

返回到可用软件视图,你可以看到该插件。选中Android Development Tools选择框,点击Install...

  1. On the subsequent Install window, "Android Deveopment Tools" should be checked. Click Finish.

在下一步的安装窗口,"Android Deveopment Tools"将会被检查,点击Finish

  1. Restart Eclipse.

重新启动Eclipse

After restart, update your Eclipse preferences to point to the SDK directory:

重启后,更新你的Eclpise参数指向SDK目录:

1.                Select Window > Preferences... to open the Preferences panel.

选择 Window > Preferences..打开参数面板。

2.                Select Android from the left panel.

在左边的列表中选择Android

3.                For the SDK Location in the main panel, click Browse... and locate the SDK directory.

在主面板中设置SDK位置,点击Browse...和定位到SDK的目录。

4.                Click Apply, then OK.

点击应用然后OK

Installing the Eclipse Plugin (WDT)

安装Eclipse插件(WDT

If you will be using the Eclipse IDE as your environment for developing widget applications, you can install a custom plugin called Widget Development Tools (WDT), which adds integrated support for widget projects and tools. The WDT plugin includes a variety of powerful extensions that make creating, editing, running and debugging widget applications faster and easier.

如果你使用ECLIPSE IDE作为你开发Widget应用程序的环境,你可以安装一个叫做Widget开发工具的插件,它加入了Widget项目和工具的整合支持。WDT插件包含了各种强大的扩展,让创建,编辑,运行和调试Widget应用程序更加快捷和方便。

Download the WDT zip file (do not unpack it). The WDT zip is also available in the SDK (SDK folder/tools/jil-wdt-site.zip).

下载WDT zip文档(不要解压缩它)。WDT zip同样在SDK中提供(SDK folder/tools/jil-wdt-site.zip

For Eclipse 3.4 (Ganymede)

  1. Start Eclipse, then select Help > Software Updates....

启动Eclipse,选择Help > Software Updates....

  1. In the dialog that appears, click the Available Software tab.

在出现的对话框中,点击Available Software选项页。

  1. Click Add Site..., then Archive...

点击Add Site...,然后点击 Archive...

  1. Browse and select the downloaded the zip file.

浏览和选择下载的zip文件。

  1. Back in the Available Software view, you should see the plugin. Select the checkbox next to Widget Development Tools and click Install...

返回到可用软件视图,你可以看到该插件。选中Widget Development Tools选择框,点击Install...

  1. On the subsequent Install window, "Widget Deveopment Tools" should be checked. Click Finish.

在下一步的安装窗口," Widget Deveopment Tools "将会被检查,点击Finish

  1. Restart Eclipse.

重启Eclpise

After restart, update your Eclipse preferences to point to the SDK directory:

重启后,更新你的Eclpise参数指向SDK目录:

1.                Select Window > Preferences... to open the Preferences panel.

选择 Window > Preferences..打开参数面板。

2.                Select Widget from the left panel.

在左边的列表中选择Widget

 

3.                For the SDK Location in the main panel, click Browse... and locate the SDK directory.

在主面板中设置SDK位置,点击Browse...和定位到SDK的目录。

4.                Click Apply, then OK.

点击Apply然后OK

Hello, OMS!

OMS application is compatible with Android application. So you can create your first OMS application “Hello, OMS” according to the “Hello, Android” guideline of android. Please refer to Hello Android.

OMS应用程序与Android应用程序兼容。你可以依照android “Hello, Android”的向导创建你的第一个OMS应用程序“Hello, OMS”。请参考Hello Android.

Compared with Android, OMS provides many OMS APIs to extend the functionality of OMS platform.

Android对比,OMS提供许多OMS APIs拓展OMS平台的功能。
Following steps will create a simple Activity that output all call log in the phone (also includes the calls that have already been deleted from phone’s Call Log). We implement it by using Local Search API.

按照以下几个步骤,可以创建一个简单的活动,输出所有电话记录(包括已经被删除的电话记录)。我们通过使用Local Search API实现它。

Create the Project

创建项目

·                                Before continuing the first step, you’ll need to have a development computer with the Eclipse IDE installed. And please be sure that the ADT has been installed as a plugin of Eclipse(see Installing the Eclipse Plugin for more detail).

开始第一步之前,你需要一台安装了Eclipse IDE 的电脑。并且确认已经安装ECLIPSEADT插件(请回看Installing the Eclipse Plugin获得细节)。

  1. Create a new Android Project

From Eclipse, select the “File > New > Android Project” menu item.

创建一个新的Android项目

Eclipse中,选择File > New > Android Project”菜单项。

  1. Fill out the project details

The next screen allows you to enter the relevant details for your project. Here&apos;s an example:

填写项目信息

下一步的屏幕让你输入项目的相关细节,下面是一个例子:

  1. Add OMS library to the project

Set focus at the created project. After that, at the “Package Explorer” window of Eclipse, the just created project&apos;s title is choosed.
Click at Eclipse&apos;s menu item “Project -> Properties”. In the popup window, click the tab icon “Libraries”.
And then you can see the window looks like this:

添加OMS库到项目

焦点定位到创建的项目树种,选中创建的项目。然后,在Eclipse“Package Explorer”中,点击菜单项Project -> Properties”,在弹出的窗口中,点击Libraries”页。你会看到如下窗口:

Click at the button “Add Library...”

点击“Add Library...”按钮

Choose “User Library”, then “Next >”

选择“User Library”然后下一步

Now, the window should looks like the image below. If not found the item names “OMS”, please click at “User Libraries...” to add a User Library(see detail at Adding OMS Library to Build Path in Eclipse IDE).

现在,出现如下的窗口。如果没有“OMS”的选项,请点击User Libraries...”添加一个用户库(详情请见 Adding OMS Library to Build Path in Eclipse IDE

Choose the “OMS”, and click at “Finish”. And the Properties page now should looks like following.

选择“OMS”用户库,点击Finish”。然后属性页如下图所示。

 

Now, an OMS project has been successfully created. You&apos;ll have a class named HelloOms with source code looks like this:

现在,一个OMS项目已经成功创建,你将会发现一个类名称HelloOms,源代码如下面所示:

         public class HelloOms extends Activity {
                 /** Called when the activity is first created. */
                 @Override
                 public void onCreate(Bundle icicle) {
                          super.onCreate(icicle);
                          setContentView(R.layout.main);
                 }
         }

Programming OMS

OMS编程

·                                Next, we will modifying the auto generated code, try adding code using OMS API!

下一步,我们修改自动生成的代码,尝试使用OMS API添加代码

Main tasks are:

主要任务有:

1.                            create a scrollable text view on the screen

在屏幕上创建一个可滚动的文本视图

2.                            call OMS API

调用OMS API

3.                            print result of step 2 to the text view created at step 1.

打印步骤2的结果在步骤1创建的文本视图上。

·                                Construct the UI by XML layout

通过XML布局构建UI

Open the main XML layout file res/layout/main.xml with “Android Layout Editor”. Change it to following codes shown.

Android布局编辑器(“Android Layout Editor”)打开主要XML布局文件 res/layout/main.xml 。切换到代码显示。

        <?xml version="1.0" encoding="utf-8"?>
        <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
                 android:layout_width="fill_parent"
                 android:layout_height="fill_parent">
                 <TextView android:id="@+id/textview"
                          android:layout_width="fill_parent"
                          android:layout_height="wrap_content" />
        </ScrollView>

Have a TextView with id “textview”. The TextView&apos;s property value of “layout_height” is set as “wrap_content”, so that all content of the view is visible. Encapsulate the TextView in a ScroolView(应该为ScrollView to enable the scroll ability for shown content.

有一个TextView,id名叫“textview”TextView“layout_height”属性值是设置“wrap_content”,因此所有视图内容都是可视的。总的来说,TextView是一个ScrollView(滚动视图),赋予内容滚动显示能力。

·                                Java code with OMS API(LocalSearch)

使用OMS APIJava代码(本地搜索)

Next is to modify the java file of oms/hello/HelloOms.java, add code to call LocalSearch API.

下一步是修改JAVA文件oms/hello/HelloOms.java,添加代码调用LocalSearch API

package oms.hello;
 
import ...
import oms.servo.search.SearchProvider;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
 
public class HelloOms extends Activity {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle icicle) {
 
                 ...
                 
                 // step 2: call OMS API(LocalSearch)
                 String searchSelection = "type:" + SearchProvider.TYPE_CALL;
                 String searchResult = localSearch(searchSelection);
        }
 
        public String localSearch(String searchSelection) {
                 // search for SMS
                 Uri uri = Uri.parse(SearchProvider.CONTENT_URI);
                 Cursor cursor = getContentResolver().query(uri, null, searchSelection,
                                  null, null);
 
                 // set the result
                 StringBuffer result = new StringBuffer();
                 result.append("#launch_uri      #calltype       #title(#number) #time(#duration)/n");
 
                 while (cursor.moveToNext()) {
                          // Use cursor.respond function to get the data.
                          Bundle extras = new Bundle();
                          extras = cursor.respond(extras);
                          // Extract the data from search result
                          String itemuri = extras.getString(SearchProvider.FIELD_LAUNCH_URI);
                          String title = extras.getString(SearchProvider.FIELD_TITLE);
                          String calltype = extras.getString(FIELD_CALL_TYPE);
                          String number = extras.getString(FIELD_CALL_NUMBER);
                          String time = extras.getString(FIELD_TIME);
                          int duration = Integer.parseInt(extras.getString(FIELD_CALL_DURATION));
                          result.append("/n").append(itemuri)
                                  .append("/n[").append(calltype).append("]")
                                  .append("/t").append(title)
                                  .append("(").append(number).append(")")
                                  .append("/t").append(time)
                                  .append("(").append(duration).append(")")
                                  .append("/n");
                 }
 
                 cursor.close();
                 return result.toString();
        }
 
        public static final String FIELD_CALL_TYPE = "calltype";
        public static final String FIELD_TIME = "display_date";
        public static final String FIELD_CALL_NUMBER = "number";
        public static final String FIELD_CALL_DURATION = "duration";
}

Here, requested data is read from the Provider of LocalSearch. A cursor is returned from the Query request.
Next is to enumerate the cursor, read each field needed. Use StringBuffer to collect the result.
As the final result, “String searchResult”is returned as the readable result from LocalSearch API.

这里,请求数据由LocalSearch的提供者读出。查询请求返回一个游标。

下一步枚举游标,读取每一个需要字段。使用StringBuffer收集结果。

作为最终结果,LocalSearch API 返回一个可读的“String searchResult”结果。

·                                Output the result

A variable “searchResult” is get at previous step. Now you can get the TextView, and set the result String to it.

“searchResult”变量是初步步骤。现在你可以使用TextView,设置返回的STRINGTextView

package oms.hello;
 
import ...
import android.widget.TextView;
 
public class HelloOms extends Activity {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle icicle) {
 
                 ...
 
                 // step 3: output the result to the TextView
                 if (searchResult != null) {
                          TextView tv = (TextView) findViewById(R.id.textview);
                          tv.setText(searchResult);
                 }
        }
}

Run/Debug OMS

运行/调试 OMS

·                                Next, we will run and debug the OMS application. Actually this step is very like the corresponding step in “Hello Android”.
Right click at the newly created project. From the popup menu, click at “Run As -> Android Application”.
You can also click at the menu(“Run -> Run As”) to run it.

下一步,我们将要运行和调试OMS应用程序。实际上这个步骤与相对应的“Hello Android”相似。右键点击新建项目。从弹出的菜单中,点击“Run As -> Android Application”

你也可以单击菜单(Run -> Run As”)运行它。

 

If the device is not connected with the computer, an emulator will be launched before deploying and running the application.

如果设备没有与电脑连接,在部署和运行程序前一个仿真器就会被启动。

 

Hello, Widget!

Now Let's start to write your first OMS widget application. It's pretty easy. Here's how it looks:

现在,我们开始写一个OMS Widget 应用程序。相当容易。下面就是步骤:

创建一个Widget项目

运行代码:Hello,Widget

Create the Widget Project

创建Widget项目

Creating the project is as simple as can be. An Eclipse WDT plugin is available making OMS widget development a snap.

创建项目是非常简单。Eclipse WDT插件使得OMS Widget开发非常便捷。

You'll need to have a development computer with the Eclipse IDE installed (see Install the OMS SDK), and you'll need to install the Install the Eclipse Plugin (WDT). Once you have those ready, come back here.

你需要一台安装了Eclipse IDE的开发电脑(请参考Install the OMS SDK),然后你也需要安装Install the Eclipse Plugin (WDT)。一旦你已经准备好,请回到这里。

First, here's a high-level summary of how to build "Hello, Widget!":

首先,这里概括怎么建立"Hello, Widget!"

  1. Create a new "Widget Project" via the File > New > Project menu.

创建一个新的"Widget Project",通过File > New > Project菜单。

  1. Fill out the project details in the New Widget Project dialog.

在新建Widget Project对话框里填写项目细节。

  1. Edit the auto-generated source code template to display some output.

辫子自动生成源代码模版显示一些输出。

That's it! Next, let's go through each step above in detail.

好了,下一步我们通过一步步来做。

1.                Create a new Widget Project

创建一个新的Widget Project

From Eclipse, select the File > New > Project menu item. If the WDT Plugin for Eclipse has been successfully installed, the resulting dialog should have a folder labeled "Widget" which should contain a single entry: "Widget Project".

Eclipse中,选择File > New > Project菜单项。如果WDT插件已经成功安装,结果是对话框中将会有一个标签叫做“Widget”的文件夹,它包含一个简单的条目:"Widget Project"

Once you've selected "Widget Project", click the Next button.

一旦你选中了"Widget Project",点击Next按钮。

2.                Fill out the project details

填写项目细节

The next screen allows you to enter the relevant details for your project. Here's an example:

下一屏幕允许你输入有关的项目细节。下面是一个例子:

Here's what each field on this screen means:

下面是屏幕中每一个域的意思:

Project Name

项目名

This is the name of the directory or folder on your computer that you want to contain the project.

电脑中目录或者文件夹的名字,你想要控制项目

Contents

内容

You can create a new widget project , the base project files will be created automatically. You can also select create project from exsiting source files.

你可以创建一个新的Widget项目,基础的项目文件将会自动创建。你也可以从一个存在的源文件中创建项目。

Use default location

使用缺省路径

The checkbox for toggling "Use default location" allows you to change the location on disk where the project's files will be generated and stored.

选择框选中"Use default location",允许你改变硬盘上的路径,这个路径用来产生和存储项目文件。

 

 

Project Name

This is the name of the directory or folder on your computer that you want to contain the project.

Contents

You can create a new widget project , the base project files will be created automatically. You can also select create project from exsiting source files.

Use default location

The checkbox for toggling "Use default location" allows you to change the location on disk where the project's files will be generated and stored.

3.                Edit the auto-generated source code

编辑自动生成的源代码

After the plugin runs, you'll have a project named HelloWidget (found in the Package Explorer of Eclipse IDE). It should look like this:

插件运行完毕后,你将会有一个叫HelloWidget的项目(在Eclipse IdePackage Explorer中)。如下所示:

As shown in above figure, there are some project files generated automatically:

如上图所示,自动产生了系列项目文件:

o          HelloWidget.html

§           The HTML file is the frame of the widget, you can define the style type in the css file, and if there is complicated logic, you can implement it in javascript file.

HTML文件是widget的框架,你可以通过css文件定义风格,或者,你可以通过javascript实现结构复杂的逻辑。

o          HelloWidget.js

§           The JavaScript file is used to implement the widget logic.

Javascript文件用来实现widget逻辑。

o          HelloWidget.css

§           The css file contains the style sheet for the widget.

Css文件控制widget的风格式样表。

o          config.xml

§           The xml file contains the needed information of the widget.

Xml文件包含了widget必须的信息。

o          Default.png

§           The Icon.png is an icon that will be shown in the list of the widgets that installed. Default.png is a background picture for the widget. It can be named as you like, but it has to be registered in the file 'Info.plist'.

icon.png是一个被现实在已经安装的widgets列表中的图标。Default.png是一个widget的背景图。你可以自己取名字,不过它一定要在文件中定义。

o          Icon.png

§           The Icon.png is the icon image of the widget

Icon.pngwidget的图标文件。

o          HelloWidget.wdgt

§           The *.wdgt file is the widget package that can be installed to OMS emulator or real phone.

*.wdgt 文件是widget的包,它可以被安装到OMS的仿真器或者真的手机上。

Now, you can start the widget on the OMS emulator.

现在你可以启动widget仿真器

Run the Code: Hello, Widget

运行代码:Hello, Widget

The Eclipse plugin makes it very easy to run your applications. Begin by selecting the Run > Open Run Dialog menu entry (in Eclipse 3.4, it's Run > Run Configurations). You should see a dialog like this:

Eclipse插件使得运行你的应用程序非常简单。开始选择Run > Open Run Dialog菜单项(Eclipse 3.4, Run > Run Configurations).你将会看到如下对话框:

Next, highlight the "Widgeet Application" entry, and then click the icon in the top left corner (the one depicting a sheet of paper with a plus sign in the corner) or simply double-click the "Widget Application" entry. You should have a new launcher entry named "New_configuration".

下一步,选中"Widgeet Application",单击左上角的图标(一个描述一张角落里带有加好的纸)或者简单双击"Widget Application"。你会看到一个新的加载入口,叫做"New_configuration"

Change the name to something expressive, like "Hello, Widget", and then pick your project by clicking the Browse button. (If you have more than one OMS widget project open in Eclipse, be sure to pick the right one. Here, we select "HelloWidget")

改一个描述它的名字,例如"Hello, Widget",然后,点击Browse按钮,选择你的项目。(如果Eclipse中打开了不止一个OMS Widget项目,请确认选中正确的一个。这里,我们选中"HelloWidget")

Click the "Apply" button. Here's an example:

点击"Apply"按钮。以下是一个例子:

Click the Run button, and the OMS emulator should start. The widget will shown on phone screen. . Like this:

点击Run按钮,然后OMS仿真器就会启动。Widget就会相似在手机的屏幕上,请看:

You can also run the widget by Popup Menu: Right click the "HelloWidget" in package explorer, then click the "Run As " popmenu, and select "Widget Application", as shown in the following picture.

你也可以通过右键菜单运行widgetpackage 浏览器中,右键点击"HelloWidget",点击"Run As "弹出菜单,选择"Widget Application",如下图所示:

You can also start the widget by the toolbar, click "Run", and then select "Hello, Widget" item, as shown in the following picture.

你也可以通过工具条启动widget,点击"Run",然后选择"Hello, Widget"项,如下图所示:

You can also see the widget running log in the Widget conole of the Eclipse IDE. Some log information has been listed as follows:

你也可以看到在Eclipse IDE widget控制台中看到widget运行的日志。一些日志信息如下文所示:

[2009-04-09 13:48:59 - HelloWdiget] ------------------------------

[2009-04-09 13:48:59 - HelloWdiget] Widget Launch!

[2009-04-09 13:48:59 - HelloWdiget] adb is running normally.

[2009-04-09 13:48:59 - HelloWdiget] Automatic Target Mode: using existing emulator: emulator-5554

[2009-04-09 13:48:59 - HelloWdiget] Uploading HelloWidget.wdgt onto device 'emulator-5554'

[2009-04-09 13:49:02 - HelloWdiget] ActivityManager: Broadcasting: Intent { action=android.intent.action.EDIT data=file:///local/HelloWidget.wdgt type=vnd.android.cursor.item/vnd.borqs.widgetdebug comp={oms.widgetplayer/oms.widgetplayer.debug.DebugReceiver} }

 

 

三、API Reference

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值