Question
I'm developing a hybrid application on Tizen 2.3.1. The app runs fine in the foreground, but when I send it to the background, it continues running for a while before unexpectedly restarting. How can I ensure my hybrid app can run indefinitely in the background?
Answer
Problem Understanding
Tizen OS has implemented resource management policies that restrict background processes to optimize power consumption. Starting from version 2.3.1, the system may terminate background applications unless they are properly configured with appropriate background categories in the manifest file.
Solution Methods
-
Enable Background Support:
- Open your project's config.xml file
- Navigate to the 'Tizen' tab
- Under 'Settings', enable 'Background-support'
-
Add Background Category:
- Still in the 'Tizen' tab
- Go to 'Background-Category'
- Click 'Add Category' and select the appropriate category that justifies your app's need for background execution
-
Configure Tizen-Manifest.xml:
- Open Tizen-Manifest.xml
- Go to the 'Advanced' tab
- Under 'Background Category', click '+'
- Choose the relevant category for your application
Code Examples
For Tizen-Manifest.xml configuration:
<background-category>
<category>media</category> <!-- Example for a media player app -->
</background-category>
Additional Tips
- Choose the background category that best matches your app's functionality
- Be aware that even with proper configuration, the system may still terminate your app if it consumes excessive resources
- Regularly test your app's background behavior to ensure it meets your requirements
- For more details, refer to the official documentation on background support at samsungtizenos.com