bada Tutorial: Application

bada 1.2.0 Copyright © Copyright © 2010 Samsung Co., Ltd. All Co., Ltd. All rights reserved. 2010 Samsung Electronics Electronics rights reserved. 1

Contents (1/2)
• • • • Essential Classes Relationships between Classes Overview bada Applications
– Application Model – Launching Application – Terminating Application

• Application State Transition
– Application Life-cycle – Foreground and Background

• • • •

System Events Application Framework Internationalization Launching Applications
Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 2

Contents (2/2)
• Notifications • AppControl
– – – – – – – – – – – – Application Control ID Operation ID Getting an AppControl AppControl Examples Create an Application Save and Restore Application Settings Handle Screen Events Use Sign-In Application Control Launch Other Applications and Handle Launch Arguments Example: Launching Applications Conditionally Example: Creating a Notification View New Application Details through Samsung Apps before Installation

• Examples:

• FAQ
Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 3

Essential Classes
• Major classes
Feature Provided by Application AppResource AppRegistry NotificationManager AppControl AppManager

Provides the base class to create applications. It initializes and terminates the application, and also provides handlers for system events.
Provides localized application string resources. Provides a repository to save and load user application‟s state and context. Sends notifications to the user. Provides application launching mechanism to use other application control features. Finds the specific application control.

Interfaces
Feature Provided by IAppFrame IAppControlEventListener

Provides an interface to the application frame. Provides a listener for AppControl.

Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.

4

It does not belong to the App namespace. NotificationManager Copyright © 2010 Samsung Electronics Co.Relationships between Classes <<interface>> IAppControlEventListener AppManager Application <<interface>> IAppFrame OnAppControlCompleted() FindAppControl() AppControl AppRegistry Start() MyApplication AppResource Note: This is an external class created by the developer. Ltd. All rights reserved.. 5 .

• Key features include: – Application framework.. – Application Control. – Background and foreground event handling. Ltd. All rights reserved. 6 .Overview • The App namespace contains classes and interfaces that provide the foundations for developing bada applications. Copyright © 2010 Samsung Electronics Co.

bada Applications The application framework provides: – Application life-cycle management: • Initialization and termination • Background and foreground handling – Event handling: • Battery and memory events Your Application Application Framework – Application control: • Dial. contact. 7 . and messaging Operating System Copyright © 2010 Samsung Electronics Co. media. Ltd.. browser. All rights reserved.

– bada applications: • Installable and removable applications. the word “application” refers to a bada application. Camera.. there are two application types: – Base applications: • Stored in the ROM and not removable via the Application manager. Dialer. and Music player.Application Model (1/2) In the bada platform. • In this document. • For example. All rights reserved. Ltd. Copyright © 2010 Samsung Electronics Co. 8 . Contact.

• An application can utilize various device platform features provided by application controls through the AppControl class. 9 . • bada platform task management • Only one bada application can run at a time. the first is always terminated by the platform. Ltd. Copyright © 2010 Samsung Electronics Co.Application Model (2/2) • A bada application running in the foreground is sent to the background when base applications are launched.. • Multi-tasking is available between a bada application and base applications. for example when receiving an incoming voice call or user switching to home screen. one bada application can run simultaneously with multiple base applications. – If a bada application is already running when launching another bada application. That is. All rights reserved.

and previous application states can be loaded or initialized.. resources. Ltd. All rights reserved. In the application initialization phase (OnAppInitializing()). UI components. 10 . The application‟s entry point (OspMain()) creates an instance of the application and executes it.Launching Application • • • • An application is launched when the user clicks the icon in the main menu. The system loads the necessary libraries and application executable binary to the memory. Main menu Application int OspMain() Copyright © 2010 Samsung Electronics Co.

When the application is in the foreground. • The system forces the application to shut down: 1. the user pressing the End key terminates the application. All bada applications follow a single bada application policy.. When memory or battery power is extremely low. the first application is terminated.Terminating Application (1/2) • The application closes for one of 2 reasons: 1. so only one bada application can run at a time. All rights reserved. 2. the system terminates the application. Copyright © 2010 Samsung Electronics Co. If a second application launches while the first is running. 2. 11 . the application is terminated. Ltd. When the bada application itself calls the Application::Terminate() method.

It is: • True. Form. – The application must free the resources it has been using to avoid memory leakage. Copyright © 2010 Samsung Electronics Co. False. – The application must close all pending connections to servers. which is called when the application terminates. and their child controls. low battery. – The application can save its own state or context through AppRegistry. – The forcedTermination argument specifies that the application is being terminated by the system. 12 . or other system interruptions. when the application is launched. are released before the OnAppTerminating() method is called. such as the Frame. when the termination is initiated by the user pressing the End key or closing the application from the task manager. it can resume from the last form from the previous execution. Ltd. or by the application calling Terminate() itself.Terminating Application (2/2) Application termination tasks must be handled in the OnAppTerminating() method. for example due to second bada application launching. When terminating: – The application must close quickly.. For instance. when the application is forced to terminate. All rights reserved. • The allocated UI control objects. They are not accessible from within the OnAppTerminating() method.

Ltd.Application State Transition (1/2) Applications have the following states with corresponding event handlers: – Initializing • Application framework initializes the application and creates the application‟s frame.. 13 . Copyright © 2010 Samsung Electronics Co. – Running – Terminating • The application exits the event loop and frees its own resources. All rights reserved. • If the OnAppInitializing() method returns false. • If the OnAppInitializing() returns true. the application framework proceeds to „Running‟ state. application state changes to „Terminating‟ and it exits.

Register application context in the system. .Exit event loop. All rights reserved.Call the application‟s OnAppInitializing() method.Application destroyed. . Initialization succeeds Create Initializing Initialization fails Terminating Running Termination . Ltd.Destroy allocated resources. . .Process events. .Application State Transition (2/2) – Terminated • It releases the control of the flow to the system.Create the application frame .Call the application‟s OnAppTerminating() method. 14 . . Terminated Copyright © 2010 Samsung Electronics Co. ..

15 . All rights reserved..Application Life-cycle The diagram illustrates where the application state events occur in terms of the application life-cycle. Application Launch Showing splash image Hiding splash image OnAppInitializing() Application comes to the foreground OnForeground() Running OnBackground() Another window comes to the foreground (for example. a system popup or another application) Termination OnAppTerminating() Application Exit Application life-cycle Copyright © 2010 Samsung Electronics Co. Ltd.

Ltd. 16 . – When the system needs to refresh a screen component. – When an application is first launched.. Copyright © 2010 Samsung Electronics Co. – An application is brought to the foreground from the background when: • The running application is selected from the task manager. – When the application is brought to the foreground: • Resume graphics processing (3D or animation) since the application now has focus. it can call the OnForeground()method even if the application is present in the foreground. All rights reserved. the OnForeground()method is called.Foreground and Background (1/3) Foreground: – Applications are visible when they are in the foreground. • The application icon is selected in the main menu. • Resume the operations which were stopped when the application was last moved to the background.

Home key pressed .Icon pressed in the main menu Copyright © 2010 Samsung Electronics Co. • Release unnecessary resources.OnForeground() is called Foreground Background . – An application moves to the background when : • The Home key is pressed. All rights reserved.) since they will not be displayed anyway. • Stop media processing.OnBackground() is called -Selected from the task manager . such as windows for incoming calls and alarms.Foreground and Background (2/3) Background: – Applications are not visible when they are in the background.Other windows pop up . etc.. haptic and sensors manipulations. – When the application is sent to the background: • Stop graphics processing (3D. 17 . Ltd. animation. • Other windows pop up. .

18 . Ltd.. Copyright © 2010 Samsung Electronics Co. All rights reserved.Foreground and Background (3/3) The following diagram illustrates the various events and states from the application and the application framework‟s perspective.

such as the camera and media player. Copyright © 2010 Samsung Electronics Co. terminate the application. • Memory event: When memory is low. the OnLowMemory() event handler is called. since they are not guaranteed to function properly at this battery level. Free unused memory from the heap in this event handler. 19 . – If the level is CRITICAL.System Events (1/3) System events must be properly handled by the Application class event handlers: • Battery event: Applications that use multimedia resources. All rights reserved. stop using multimedia features. Ltd.. need to check the battery level in the OnBatteryLevelChanged() event handler: – If the level is EMPTY.

Copyright © 2010 Samsung Electronics Co.System Events (2/3) Screen event: – Applications can receive screen events in OnScreenOn() and OnScreenOff() event handlers if they register a screen event listener. such as 3D. 20 . – The resources must be handled efficiently by the OnForeground()/ OnBackground() and OnScreenOn()/OnScreenOff() event handlers. – The following events are triggered when the backlight time expires: • OnScreenOff() • If device is in auto lock mode. Be careful not to duplicate or delete resources. – When the device is in auto lock mode. All rights reserved. multimedia. Ltd. When the OnScreenOff() event handler is triggered. which are no longer used. OnBackground() is called after OnScreenOff() when the lock UI is displayed. The released resources can be acquired again when the OnScreenOn() event handler is triggered. and sensors. the application must reduce power consumption by releasing the activated resources.. OnBackground()is called directly after OnScreenOff().

• OnForeground() is called after the lock UI disappears. All rights reserved. only OnBackground() is called after the lock UI is displayed. Ltd. OnScreenOn() is triggered. – When the lock key is pressed explicitly. 21 .System Events (3/3) – The following events are triggered when the unlock key is pressed. When the backlight turns off.. OnScreenOff() is called. Copyright © 2010 Samsung Electronics Co. • If the touch lock is enabled.

22 .Application Framework • • Application AppManager Application: – All applications must derive from Application class IAppFrame AppResource AppManager: – Application manager class – Finds an AppControl instance AppControl AppRegistry NotificationManager • • • • IAppFrame: – UI frame interface – Frame is the main window in an application AppResource: – Application resource class – Can contain localized strings AppControl: – Application control class – Used to start an application and control specific behavior NotificationManager: – Notification manager class – Used to alert the user about notifications Copyright © 2010 Samsung Electronics Co. Ltd. All rights reserved..

xml [IDE String Resource] • AppResource handles localized string resource based on preferred display language that is defined in the device settings. – For example: eng-GB.xml. kor-KR.Internationalization (1/2) • String resource is supported for multiple languages. fra-FR. Ltd.xml Menu Back Language Setting Copyright © 2010 Samsung Electronics Co.xml. Your App Form AppResource “Hello” eng-GB.xml. deu-DE. 23 .xml. Each localized string is saved to each xml file in Res folder. All rights reserved. ita-IT..

String str1. 2. String& loadedString) Application* pApp = Application::GetInstance(). Ltd. Prepare the localized strings table with the UI Builder.Internationalization (2/2) Retrieving localized strings 1. For more information.. str1). r = pApp->GetAppResource()->GetString("IDS_STRING1". AppResource retrieves the chosen language from the display language settings and returns the localized strings. 24 . Get the localized string from the AppResource class. Copyright © 2010 Samsung Electronics Co. All rights reserved. see Using String Tables in the Development Environment tutorial. – AppResource::GetString(const String& id.

Therefore. and to use the method. 25 . and the calling application is terminated. see the API Reference. you must assign the APP_SERVICE privilege group to your application. Copyright © 2010 Samsung Electronics Co. – You can retrieve the launch arguments from an application by using the Application::OnUserEventReceivedN() method.Launching Applications (1/2) Launching other applications: – A bada application can launch other applications using the AppManager::LaunchApplication()method. – The AppManager::LaunchApplication() method requires the SYSTEM privilege level. – All bada applications follow the single application policy. For more information.. Ltd. All rights reserved. the OnAppTerminating() method is called immediately after the LaunchApplication() method.

Ltd. If the application is running. unless the application is already running. a notification is delivered in the Application::OnUserEventReceivedN() event hander. All rights reserved. 26 .Launching Applications (2/2) Launching applications with conditions: – A bada application can launch itself with a specified condition using the AppManager::RegisterAppLaunch() method with the SYSTEM privilege level and APP_SERVICE privilege group. – A launch condition can be specified as follows: Type Due time Condition format L”DataTime=„mm/dd/yyyy hh:mm:ss‟” Description Launch at the local time „mm/dd/yyyy hh:mm:ss‟ . Launch on the serial communication input „command‟. – The application is newly launched when the condition is fulfilled. Serial L”Serial=„command‟” Copyright © 2010 Samsung Electronics Co. The time format matches the output format of Base::DateTime::ToString()..

27 . • The NotificationManager::Notify() method requires the NOTIFICATION privilege group. All rights reserved. • A notification can be a combination of the following types: Ticker Quick panel Badge number Sound Copyright © 2010 Samsung Electronics Co.. you must define an icon for the ticker or quick panel in the application properties.Notifications • An application can notify the user using the NotificationManager::Notify() method. Ltd. In addition.

• AppManager finds the service providing application control and returns it for your application to use. For example. Copyright © 2010 Samsung Electronics Co. APPCONTROL_DIAL. – Operation ID: • Defines the variable for identifying the behavior of each application control instance. For example. All rights reserved. • AppControl instance can be created from the AppManager. OPERATION_VIEW.. • AppControls can be identified using 2 parameters: – Application Control ID: • Defines the variable for identifying each application control instance.AppControl (1/2) • AppControl is a standard mechanism for using specific operations exported by base applications • AppControl can communicate data and get back results. Ltd. 28 .

Call and Browser requires Normal privilege. – OnAppControlCompleted() is invoked when an application finishes its operation and a control callback event occurs. Ltd. All rights reserved. Copyright © 2010 Samsung Electronics Co. 29 . • Some AppControls require privileges to use them: – For example..AppControl (2/2) • The result of the application control‟s execution is returned by IAppControlEventListener‟s OnAppControlCompleted() method.

The event details are displayed only if the vCalendar (event) file path or the record ID of the event (used in Social::Calendarbook) is specified. This operation can be used to open a Web browser using the specified URL. This operation can be used to edit a contact in the contact database. Using this AppControl requires special privileges. This operation can be used to view a vCard file. email address. Ltd. This application control can be used to launch the Dial UI. or vCard file path for one or more contacts in the contact database. All rights reserved. Using this AppControl requires special privileges. 30 OPERATION_EDIT OPERATION_VIEW APPCONTROL_CALENDAR OPERATION_PICK OPERATION_VIEW APPCONTROL_DIAL OPERATION_DEFAULT APPCONTROL_CALL APPCONTROL_BROWSER OPERATION_DEFAULT OPERATION_DEFAULT . The to-do item details are displayed only if the vCalendar (to-do) file path is specified. This operation can be used to call the specified number.Application Control ID (1/3) AppControl name APPCONTROL_CONTACT Operation ID OPERATION_PICK OPERATION_ADD Description This operation can be used to read the phone number. Users can edit this number and make calls using the Call key. This operation can be used to view a vCalendar file or a calendar event. such as events.vnt files. The parameter passed to this application control is displayed on the screen.vcs files and memo items as . This operation can be used with either the single or the multiple selection feature to select one or more Calendar application items. or memos. contact ID. to-do items. The parameters passed to this AppControl are automatically filled in the appropriate fields in the Add Contact UI. The parameters passed to this AppControl are automatically filled in the appropriate fields in the Edit Contact UI. This operation can be used to add a contact to the contact database.. Copyright © 2010 Samsung Electronics Co. Event and to-do items are returned as . The contact details are displayed only if the vCard file path is specified.

Ltd. This operation can be used to sign out from the bada Server. Using this AppControl requires special privileges. this operation handles all subsequent sign-ins automatically. This operation can be used to compose SMS or MMS messages. All rights reserved. After the user has signed in for the first time. This operation can be used to obtain the details of a Bluetooth profile on the device. This operation can be used to compose email messages.. Using this AppControl requires special privileges. OPERATION_SIGNOUT APPCONTROL_CAMERA APPCONTROL_MESSAGE OPERATION_CAPTURE OPERATION_EDIT APPCONTROL_EMAIL OPERATION_EDIT APPCOTNROL_BT OPERATION_PICK Copyright © 2010 Samsung Electronics Co.Application Control ID (2/3) AppControl name APPCONTROL_SIGNIN Operation ID OPERATION_SIGNIN Description This operation can be used to sign in to the bada Server. The parameters passed to this application control are automatically filled in the appropriate fields in the displayed message composer. 31 . This operation can be used to launch the Camera UI to capture images or record video. This operation signs out without displaying any dialog. The parameters passed to this application control are automatically filled in the appropriate fields in the displayed message composer.

Application Control ID (3/3) AppControl name APPCONTROL_MEDIA Operation ID OPERATION_PICK Description This operation can be used to select one or more media files . This operation can be used to view the settings of a specific feature category. This operation can be used to play audio files on the device. All rights reserved. APPCONTROL_IMAGE APPCONTROL_VIDEO APPCONTROL_AUDIO APPCONTROL_SETTINGS OPERATION_VIEW OPERATION_PLAY OPERATION_PLAY OPERATION_DEFAULT Copyright © 2010 Samsung Electronics Co. This operation can be used to view image files on the device. 32 . Ltd.. This operation can be used to play video files on the device. Currently. only the location category is supported. from the My Files folder. such as images or video recordings.

Operation ID OPERATION_ADD OPERATION_CAPTURE OPERATION_EDIT OPERATION_DEFAULT OPERATION_PICK OPERATION_PLAY OPERATION_VIEW Description Adds an item or content to a specific AppControl. All rights reserved. Edits an item or content in a specific AppControl. Captures an item or content in a specific AppControl. Copyright © 2010 Samsung Electronics Co. Signs out of a session. 33 . Obtains data from a specific AppControl. Displays an item or content in a specific AppControl. Ltd. Plays an item or content in a specific AppControl.Operation ID Operations specify the specific behavior or action that must be performed. OPERATION_SIGNIN OPERATION_SIGNOUT Displays a sign-in window.. Launches the AppControl without any operation.

34 . All rights reserved. Contact) AppControl 1. AppControls Registry #Dial #Video type=“…” #SignIn type=“…” Path=“…” #Browser type=“…” Path=“…” type=“…” … type=“…” Path=“…”… Path=“…” Path=“…” … … … Copyright © 2010 Samsung Electronics Co. Start AppControl. Asynchronously send result to AppControl event listener.. bada Application AppControl Base Application (For example. Launch the application AppControl ID and operation ID. 2 Resolve the AppControl ID and operation ID.Getting an AppControl IAppControlEventListener OnAppControlCompleted() 5. 3. Ltd. AppManager [AppControl Resolver] 4. Find AppControl.

35 .AppControl Examples • APPCONTROL_MEDIA: – Launches the media application to select audio. URI. i. AppControl ID: APPCONTROL_MEDIA Operation ID: OPERATION_PICK Option: “type:video” “selectionType:single” Caller Application Media Application • APPCONTROL_DIAL: – Launches the dialer application with a pre-filled phone number. video.e. – Receives selections in an event handler. All rights reserved. or image content from the Media folder. AppControl ID: APPCONTROL_DIAL Operation ID: NONE Option: “tel:+82312798707” Caller Application Dialer Application The calling application receives information of the selected media. Ltd. Copyright © 2010 Samsung Electronics Co.. – Requires normal privilege.

cpp. All rights reserved.. Ltd. – Open \<BADA_SDK_HOME>\Examples\UIApplication\src \HelloWorld. 1.Example: Create an Application (1/2) This example illustrates how application default methods are created. Copyright © 2010 Samsung Electronics Co. 36 . Create the HelloWorld application code using the Form Based Application template.

it contains other information necessary for your application. Application Name GetAppName() Application Application ID GetAppId() Secret Code GetAppSecret() Manifest. Ltd. such as privileges and device profiles. ID.xml MyApplication Copyright © 2010 Samsung Electronics Co.Example: Create an Application (2/2) Notes – Applications must derive from the Application class. – You must create and download your application‟s manifest. secret code). 37 .. In addition to the information above (name.xml file from bada Developers. All rights reserved.

value) Copyright © 2010 Samsung Electronics Co..Example: Save and Restore Application Settings (1/2) Save and restore application state. use AppRegistry to retrieve application settings: AppRegistry::Get(key. 1. value) 2. the registry entry must be added: AppRegistry::Add(key. Ltd. In the OnAppInitializing() method. value) 3. All rights reserved. The first time an application runs. Save application settings to disk in the registry: AppRegistry::Save() 4. 38 . Set registry values in the OnAppTerminating() event handler: AppRegistry::Set(key.

All rights reserved. (int)GameStatus). if(r == E_KEY_NOT_FOUND { appRegistry.Save(). Ltd. PLAYING. appRegistry. gamestatus). 39 . message). //enum { INIT=0. int gamestatus = GameStatus.Add("LastMessage".Save(). } appRegistry. r = appRegistry. "Who destroyed"). } // Enumeration definitions are defined elsewhere. r = appRegistry. if(r == E_KEY_NOT_FOUND { appRegistry.Get("LastMessage". PLAYING.Set("LastMessage". SCORE } GameStatus = PLAYING.Example: Save and Restore Application Settings (2/2) bool MyApplication::OnAppInitializing(AppRegistry& appRegistry) { … String message("NONE").Add("GameStatus". appRegistry. gamestatus). r = appRegistry.Get("GameStatus".. message). SCORE } GameStatus = INIT.Set("GameStatus". … } Copyright © 2010 Samsung Electronics Co. … } bool MyApplication::OnAppTerminating(AppRegistry& appRegistry) { … result r = E_SUCCESS. // enum { INIT=0.

2. if(!IsPlaying) PlaySound(). 1. bool MyApplication::OnAppInitializing(AppRegistry& appRegistry) { … PowerManager::SetScreenEventListener(*this).. then turn on sound.Example: Handle Screen Events This example illustrates how to handle a sound resource during screen on and screen off events. } Copyright © 2010 Samsung Electronics Co. Play or stop the sound using PlaySound()or StopSound() accordingly. All rights reserved. 40 . } void MyApplication::OnForeground() { if(!IsPlaying) PlaySound(). Implement the ScreenEventListener to handle screen events. … } void MyApplication::OnScreenOn (void) { // Check if sound is off. Check the sound status using the boolean value of the IsPlaying variable. Ltd. 3. } void MyApplicaiton::OnBackground() { if(IsPlaying) StopSound(). } void MyApplication::OnScreenOff (void) { if(IsPlaying) StopSound(). You can handle other resources in the same way.

this). start the AppControl by calling its Start() method: AppControl::Start(null. Copyright © 2010 Samsung Electronics Co. If the FindAppControlN() method returns an AppControl instance. delete pAc. All rights reserved. AppControl* pAc = AppManager::FindAppControlN(APPCONTROL_SIGNIN. \n"). OPERATION_SIGNIN). if(pAc != null) { pAc->Start(null. Get an AppControl instance by calling the FindAppControlN() method. 41 . } else AppLog("AppControl Not Found. Ltd. OPERATION_SIGNIN) 2.Example: Use Sign-In Application Control 1. implement an IAppControlEventListener. Provide the SignIn Control ID as parameter: AppManager::FindAppControlN(APPCONTROL_SIGNIN. this) Notes: – If you require event handlers..

. 2. terminating the caller application. requestId is assigned as a reserved launch ID (AppLaunchRequestId). 3. 1. All rights reserved. If the launch arguments exist. Ltd. A caller application launches another application with arguments using the LaunchApplication() method. The OnAppTerminating()method is called.Example: Launch Other Applications and Handle Launch Arguments (1/2) This example illustrates how to launch other applications from a bada application and retrieve the launch arguments. The called application is launched. Copyright © 2010 Samsung Electronics Co. 42 .

i < pArgs->GetCount(). 43 . // pAgrs[>=2] contains the actual arguments sent from the caller (for example. Ltd. // pArgs[0] represents the launch type (for example.Example: Launch Other Applications and Handle Launch Arguments (2/2) Caller application: … AppId calleeAppId = L”1234567890”. r = pAppManager->LaunchApplication(calleeAppId. i++) AppLog("pData[%d]=%S". pArgList->Add(*aArg). String *aArg = new String(L”yourdata”). ArrayList *pArgList = new ArrayList(). AppManager *pAppManager = AppManager::GetInstance(). AppManager::LAUNCH_OPTION_DEFAULT). Osp::Base::Collection::IList *pArgs) { if(requestId == AppLaunchRequestId) // If launch arguments exist { if(pArgs) { for(int i = 0. ((String*)(pArgs->GetAt(i)))->GetPointer()). All rights reserved. APP_LAUNCH_NORMAL value) // pArgs[1] represents the operation of the launch (default value is OPERATION_DEFAULT). pArgList->Construct(). Called application: void CalleeApp::OnUserEventReceivedN (RequestId requestId. i. pArgList. “yourdata”) … } else // Handling User Events Copyright © 2010 Samsung Electronics Co..

Define the condition in the proper String format.GetPointer()). pArrayList->Construct(). condition. pArgList. time).Format(40. The same launch argument scheme can be exploited as the LaunchApplication() method. 1. time. Ltd..ToString(). DateTime time. L”DateTime=„%S‟”. All rights reserved. 3. String condition. Time. The registered application is launched at the defined time. Copyright © 2010 Samsung Electronics Co. 2. pArgList->Add(*aArg). 44 . r = AppManager::GetInstance()>RegisterAppLaunch(condition.AddMinutes(1). Register the application for the launch with arguments using the RegisterAppLaunch() method.Example: Launching Applications Conditionally This example illustrates how to launch an application conditionally at a given time. String *aArg = new String(L”yourdata”). AppManager::LAUNCH_OPTION_DEFAULT). ArrayList* pArgList = newArrayList(). SystemTime::GetCurrentTime(WALL_TIME.

Send the notification. Copyright © 2010 Samsung Electronics Co. badgeNumber). 1. 3. 45 . Construct an instance of the NotificationManager class.”. badgeNumber++. All rights reserved. r = pNotiMgr->Notify(L”A new message has arrived. 2. Ltd. handle the badge number properly.Example: Creating a Notification This example illustrates how to inform the user with a ticker and notification.. If you want to send a badge notification. NotificationManager* pNotiMgr = new NotificationManager(). Int badgeNumber = pNotiMgr->GetBadgeNumber(). pNotiMgr->Construct().

The caller application launches the SamsungApps application with the LaunchApplication() method. All rights reserved. Copyright © 2010 Samsung Electronics Co.Example: View New Application Details through Samsung Apps before Installation (1/2) This example illustrates how you can launch the SamsungApps application to view the details of a new application on offer at Samsung Apps before deciding to download and install the new application. terminating the caller application. The SamsungApps application is launched and displays the details of the new application. using the application ID of the new application you want to view as a parameter. The SamsungApps application provides users easy access to new applications.. 46 . Ltd. 1. 4. 3. A caller application retrieves the SamsungApps application ID using the SystemInfo::GetValue()method. The OnAppTerminating()method is called. 2.

// ID of the new application whose details you want to view pArgList->Add(*aArg). All rights reserved. pArgList->Construct(). pArgList.. Ltd. r = pAppManager->LaunchApplication(samsungAppsAppId. String *aArg = new String(L”1234567890”).Example: View New Application Details through Samsung Apps before Installation (2/2) Caller application: … AppId samsungAppsAppId. ArrayList *pArgList = new ArrayList(). samsungAppsAppId). AppManager *pAppManager = AppManager::GetInstance(). 47 . Osp::System::SystemInfo::GetValue("SamsungAppsAppId". Copyright © 2010 Samsung Electronics Co. AppManager::LAUNCH_OPTION_DEFAULT).

Ltd. – Free non UI resources in the OnAppTerminating() method. and GetAppSecret() methods. but UI resources(e.xml). • Do I have to set my application‟s ID somewhere? – No. Please review the UI parts of this document about UI resource. You do not need to free them explicitly. form and its child controls) is freed automatically when the application closed.FAQ • Where do I initialize and free-up application resources? – Initialize them in the OnAppInitializing() method. an application ID (a unique identifier bound to a bada application) is created from the bada developer site and saved into the application manifest file (manifest.g. Copyright © 2010 Samsung Electronics Co. since they are member methods of the Application class.. The bada IDE does not automatically generate the GetAppId(). GetAppName(). 48 . All rights reserved.

Ltd. 49 . All rights reserved..Copyright © 2010 Samsung Electronics Co.

Sign up to vote on this title
UsefulNot useful