Saturday, September 7, 2013

AppLog, why and where

As we know, debugging is equally important as coding. Tizen provides this API for developers to help them debug code easily without the use of standard debuggers. And as a good programming practice, we should always check error codes before deploying our projects.

Now we will see shall See what AppLog does, and where can we find it.
Snap Shot:

If the Image is not visible, open it in new tab.
Explanation of the Markers.
1. Using AppLog with our custom markers (myFlag in this case).
2. The 'Log' tab in Tizen perspective, where we can see all the logs received by the emulator.
3. We can filter Log Results by putting the custom flags (myFlag in this case) there.
4. Log results.

Please Note: The log results are visible only if the program is being run in the emulator. 

Building the first Tizen App


Tizen is a operating system Jointly developed by Samsung and Intel. So being a part of that project, we had to build one. The present documentation (present on developer.tizen.org) is, not that good for beginners. So we are documenting it to make life easier for programmers.

Beginning with the basics:
1. Download and install Tizen IDE from developer.tizen.org. (Available for Windows, Mac and Ubuntu). We need to set up Security Profile and install an emulator to start testing your program.
2. We would be using the blank project template for beginning.
Screen-shot:
We would directly move on to application development, going through the following basics may help in the application development process.
  1. Application Model
  2. Application Life Cycle
  3. User Interface Basics
After all these, we are all ready to move to our first Tizen App. Till now we have made a blank application from File->New->Tizen Native Application in our IDE.

Referring to the Application Life cycle, all of the initialization should be done in HelloTizenApp::OnAppInitializing(AppRegistry& appRegistry)function, present in HelloTizen.cpp. We are just going to change this fucnction of ours.

Step 1: Initialize a Frame //This is already done for us by the Tizen IDE
     HelloTizenFrame* pHelloTizenFrame = new HelloTizenFrame;
pHelloTizenFrame->Construct();
pHelloTizenFrame->SetName(L"HelloTizen");
AddFrame(*pHelloTizenFrame);
Step 2: Initialize a form
        Tizen::Ui::Controls::Form *firstForm = new Tizen::Ui::Controls::Form();
firstForm->Construct(FORM_STYLE_NORMAL | FORM_STYLE_HEADER);

Step 3: Add form to the frame
    Tizen::Ui::Controls::Frame * frame = Application::GetInstance()->GetAppFrame()->GetFrame();
    result r = frame->AddControl(firstForm);

Step 4: Set current form of the frame to the one we just created
result r = frame->SetCurrentForm(firstForm); 
/*result variable is just to check the error codes refer help*/

Step 5: Set the Text 'Hello Tizen'
        Header *header = firstForm->GetHeader();
header->SetTitleText(L"Hello Tizen");
Step 6: Make the form visible
firstForm->Draw();
firstForm->Show();

And with all this small addition, we are up with a new application 'Hello Tizen'
Snapshot:
And this is how we see in our app in the emulator

Complete code of HelloTizenApp::OnAppInitializing(AppRegistry& appRegistry):



bool
HelloTizenApp::OnAppInitializing(AppRegistry& appRegistry)
{
// TODO:
// Initialize App specific data.
// The App's permanent data and context can be obtained from the appRegistry.
//
// If this method is successful, return true; otherwise, return false.
// If this method returns false, the App will be terminated.

// Create a Frame
HelloTizenFrame* pHelloTizenFrame = new HelloTizenFrame;
pHelloTizenFrame->Construct();
pHelloTizenFrame->SetName(L"HelloTizen");
AddFrame(*pHelloTizenFrame);


//Initializing the form
Tizen::Ui::Controls::Form *firstForm = new Tizen::Ui::Controls::Form();
firstForm->Construct(FORM_STYLE_NORMAL | FORM_STYLE_HEADER);

//TODO firstForm->AddControl( Adding more controls like Label, Buttons );

//Add the form to Tizen::Ui::Controls::Frame instance
Tizen::Ui::Controls::Frame * frame = Application::GetInstance()->GetAppFrame()->GetFrame();
 r = frame->AddControl(firstForm);
if ( r == E_SUCCESS ) //Error Checking
{
AppLog ("myFlag: Successfully added form to the frame");
}
else
{
AppLog("myFlag: Error Code is %s ", GetErrorMessage(r));
}


//THis form should be created as a default form
r = frame->SetCurrentForm(firstForm);
if ( r == E_SUCCESS )
{
AppLog ("myFlag: Successfully set current form");
}
else
{
AppLog("myFlag: Error Code is %s ", GetErrorMessage(r));
}
//Getting a Header
Header *header = firstForm->GetHeader();
header->SetTitleText(L"Hello Tizen");

//Showing the form
firstForm->Draw();
firstForm->Show();
//firstForm->Invalidate(true);

return true;
}

Friday, September 6, 2013

learning Tizen, the easy way...



Tizen is an open source, standards-based software platform supported by leading mobile operators, device manufacturers, and silicon suppliers for multiple device categories such as smartphones, tablets, netbooks, in-vehicle infotainment devices, and smart TVs. Tizen offers an innovative operating system, applications, and a user experience that consumers can take from device to device.

The Tizen project resides within the Linux Foundation and is governed by a Technical Steering Group. The Technical Steering Group is the primary decision-making body for the open source project, with a focus on platform development and delivery, along with the formation of working groups to support device verticals.

The Tizen Association has been formed to guide the industry role of Tizen, including gathering of requirements, identification and facilitation of service models, and overall industry marketing and education.

Tizen provides a robust and flexible environment for application developers, based on HTML5. With HTML5's robust capabilities and cross platform flexibility, it is rapidly becoming the preferred development environment for mobile apps and services. The Tizen SDK and API allow developers to use HTML5 and related web technologies to write applications that run across multiple device segments. [copied from tizen.org]

The best source of learning about this platform is developer.tizen.org. Tizen web programming provides a great platform for developing apps. But for low level programming or what they call: Tizen Native Apps its not a cup of tea for a beginner. So in order to simplify their approaches, we thought of coming up with a platform which can provide a basic reference to all the beginners. 

Along the way, we would be providing resources like sample codes, relevant links to developer.tizen.org