Creating Your First Application
This tutorial walks you through the creation of a simple "Hello World" application using the MoSync IDE and introduces you to some of the basic terminology we use throughout our guides, tutorials, and examples.
Creating a New Project
Start by Launching MoSync. MoSync prompts you to select a workspace:

Click OK to accept the default path. The MoSync IDE will open.
Register you copy of MoSync if you have not already done so. After registration, close the Welcome page if it is showing.
Create a new project by right-clicking in the Project Explorer view then choosing New > Project:

( If you have hidden the Project Explorer view, you can show it again by selecting Window > Show View > Other > General > Project Explorer and then clicking OK.)
When the New Project window opens, expand the MoSync folder and select MoSync Project:

Click Next.
The project name and location screen appears:

Enter the Project name "HelloWorld". (To ensure compatibility with all platforms and devices, avoid using spaces in project names. It is always safe to use the underscore character.)
Tick the Use default location box. Click Next.
A new window will open showing you the templates that are available for you new project:

For more information about these templates, see Creating Projects from Templates.
Select the MoSync Moblet Project template. Select it and click Finish.
Your new project will now be created from the template and loaded in the MoSync IDE:

Creating HelloWorld
Edit the code in the main.cpp file shown in the main window so that it looks like this:
#include <MAUtil/Moblet.h>
using namespace MAUtil;
class MyMoblet : public Moblet
{
public:
MyMoblet()
{
maSetColor(0xFFFFFF),
maDrawText(0, 32, "Hello World!");
maUpdateScreen();
}
void keyPressEvent(int keyCode, int nativeCode)
{
if(keyCode == MAK_0 || keyCode == MAK_BACK || keyCode == MAK_SOFTRIGHT)
{
close();
}
}
void keyReleaseEvent(int keyCode, int nativeCode)
{
}
};
extern "C" int MAMain()
{
MyMoblet myMoblet;
Moblet::run( &myMoblet );
return 0;
};Save your main.cpp file.
(If you would like to understand more about the code we just asked you to paste in, read our beginner's tutorial called Hello World, Deconstructed.)
Running Your Application
Your application is now ready to be built and run.
Click on your project's name in Project Explorer view so that it is highlighted.
Now click the Run button
on the IDE's toolbar (or press Ctrl+F11). Your project will be built, and your application will run in MoRE, the MoSync emulator:

Congratulations, you have now compiled and executed your first MoSync program!
What Next?
In our User Guides you will find extensive information about the MoSync IDE, including how to create projects from templates, how to use device profiles, doing bluetooth discovery and transfer, and how to use the MoRE emulator, the Debugger, the Finalizer, and MoSync's tools.
In our Programmer Guides we teach how to use MoSync's classes, functions, and syscalls in your applications, and we also provide tips for creating applications that work across multiple platforms like iPhone, Android, and Windows Mobile.
Our extensive Tutorials library covers all aspects of using the MoSync SDK to creating working applications. You will find lots of helpful code snippets here, and step-by-step instructions for common coding tasks.
We provide many Example Applications in the SDK itself, so you can see how we do it ourselves. If you are new to C/C++, we strongly recommend that you spend some time examining the code of our "Hello" series of applications: they are extremely well-commented so that you can unserstand exactly what is happening in every line of code.
At our website you can find many resources for developers, including our developer forum, and links to our code repositories and issue tracking systems.
Have fun, and good luck!
- Printer-friendly version
- Login or register to post comments
Share on Facebook