OnBackground not called

Method OnBackground() is not called when device is locked or Home key is pressed.

OnAppInitializing and OnAppTerminating works ok but OnBackground / Foreground is not called , so I can not pause the game when Home button is pressed.

App is ported from Bada. On Bada OnBackground call works fine;

Help please.

Edited by: Brock Boland on 17 Mar, 2014 Reason: Paragraph tags added automatically from tizen_format_fix module.


8 Replies
muditha murthy
Such kind of issues occures usually, if lots of operations are performed inside OnAppInitializing().keep the number of operations minimal as as possible inside OnAppInitializing() and restrict it to initialization operations only.
Przemyslaw Klosok
This is my OnAppInitializing. I think I cannot remove nothing more. Maybe the reason is that I am using a Form. bool Game::OnAppInitializing(AppRegistry& appRegistry) { //////////////////////////////////////////////////////////////////////////////////// //this codes is automatically inserted by Tizen Application Wizard. Tizen::Ui::Controls::Frame* pAppMainFrame = new Tizen::Ui::Controls::Frame(); pAppMainFrame->Construct(); pAppMainFrame->SetName(L"MainFrame"); danegry.rozmiar_x = pAppMainFrame->GetHeight(); danegry.rozmiar_y = pAppMainFrame->GetWidth(); AddFrame(*pAppMainFrame); //////////////////////////////////////////////////////////////////////////////////// Form1 *pForm1 = new Form1(); pForm1->Construct(FORM_STYLE_NORMAL); pForm1->SetOrientation(ORIENTATION_LANDSCAPE); pForm1->InitTimer(); pAppMainFrame->AddControl(*pForm1); pAppMainFrame->SetCurrentForm(*pForm1); result r; AppRegistry* pAppRegistry = GetAppRegistry(); String key; key.Clear(); key.Append(L"rekord "); r = pAppRegistry->Get(key, rek.rek); if ( r == E_KEY_NOT_FOUND) {AppLog("NOT FOUND");pAppRegistry->Add(key, rek.rek);} r = pAppRegistry->Save(); if( IsFailed(r)) { AppLog("NOT SAVED"); } datagame.iniciated = false; return true; }
Peter Holak
It works fine for me. Does your application's class inherit Tizen::App::UiApp? You may try starting from a new Tizen template and just filling all the code in there - that way you'll avoid some incompatible old bada things. You could also just have almost no code in OnAppInitializing and move it to OnAppInitialized, though I doubt it will solve your problem.
tomm chris

We must use the class, which executes in a different thread, to provide a positive user experience in our application.

Kath Rose

By keeping the number of operations performed within OnAppInitializing() to a minimum, the app can start up more quickly and with fewer performance issues. Initialization operations that might be performed within OnAppInitializing() could include setting up any necessary data structures, connecting to databases, or initializing configuration settings. Link here..


In Tizen, when an application is sent to the background or is no longer visible on the screen due to a Home key press or device lock, the OnPause() method is called instead of OnBackground(). OnPause() is where you should pause your game or release any resources that are not needed while the application is not visible.


You should also make sure that your application is properly handling the AppControl::ACTION_PAUSE and AppControl::ACTION_RESUME events, as these will be sent when the application is paused or resumed. You can handle these events in the OnAppControlReceived() minneapolis gutter cleaners method of your Tizen::App::UiApp-derived class.

Mary Solero

waterproofing contractor in philadelphia pennsylvania

The behavior you are experiencing could be due to differences in the way that backgrounding and foregrounding are handled in Tizen compared to Bada. In Tizen, an app is typically suspended when it enters the background, which means that the app's execution is paused until it is brought back to the foreground.

To pause your game when the user presses the Home key or locks the device, you can listen for the "pause" event using the Tizen application lifecycle events API. Here is an example of how you can use this API to pause your game when the app enters the background:

tizen.application.setAppPausedListener(function() { // This function will be called when the app enters the background // Pause your game here });

You can place this code in your app's initialization function (OnAppInitializing) to register the pause listener. When the app enters the background, the registered function will be called and you can pause your game logic.

Similarly, you can use the tizen.application.setAppResumedListener() method to register a listener that will be called when the app is brought back to the foreground. You can use this listener to resume your game logic.

tizen.application.setAppResumedListener(function() { // This function will be called when the app is brought back to the foreground // Resume your game here });

You can place this code in your app's initialization function (OnAppInitializing) along with the setAppPausedListener() call to register both listeners.

Note that the above code assumes that you have access to the Tizen Web API within your app. If you are using a different framework or platform, the approach may be different.

Whogan Ganni

To implement background behavior in your application, you need to ensure that you follow the guidelines and APIs provided by the mobile operating system you are developing for.