Tuesday, May 21, 2013

Mobile - Titanium4j

Titanium4j Mobile 2.0

In this tutorial we will see how to get started with Titanium4j Mobile 2. For that we will implement a simple HelloWorld program.

The requirements for this tutorial are:

- Appcelerator's Titanium Studio 2 + GWT Plugin .
- GWT 2.4.
- A Mac, if you want to try iOS simulation. Otherwise, this works for Android on Windows, too.
- The ti4j.jar file

To see how to integrate the GWT pluging in Titanium Studio please refer to our other tutorial located at : http://emitrom.com/node/19

Lets roll!

1. Create a new Mobile Application Project in Titanium Studio. Fill in the details and click Finish.



After you clicked Finish Titanium Studio will generate a structure looking like in the following image :



Later on we will edit the app.js file

2. Now create the GWT project. Fill in the details and click Finish.



3. Add ti4j.jar to the project's classpath.Make sure you give ti4j.jar a higher priority then the GWT SDK like in the following pic



4. Inherit the Titanium4j Mobile module.



5. Now that everything is set let s write some code.



Like you can see Titanium4j 2.0 provide a more better API then version 1. To see what s new in version 2 refer to our blog : http://emitrom.com/blog


6. Compile the java code from the GWT project to the Titanium Project.It is imortant that the -war argument points to the Resource folder of your Titanium project (see image below)



7. Modify the app.js file in the Titanium project to include the gerated JavaScript file from GWT. The code might look different for you depending on how you named your GWT project.



8. Running the Titanium project (Right click -> Run as ) should give the following result



For getting really creative, the Titanium API documentation is an excellent source for reference material. The beauty of it is that we match exactly their API, so you'll find an analogous Java counterpart to each and every one of their Javascript functions. Also, as a GWT project, you can take advantage of cool GWTisms, such as I18N, RequestBuilder, etc. In our next tutorials, we'll explore some of these features.


Reference:
http://emitrom.com/node/210
http://emitrom.com/forum/29

0 comments:

Post a Comment