Question
I'm developing an application that uses Bluetooth functionality. When I try to search for nearby devices using bt_adapter_start_device_discovery(), the function returns BT_ERROR_PERMISSION_DENIED.
I followed the official guide at: https://developer.tizen.org/development/guides/native-application/connectivity-and-wireless/bluetooth
What should I do to resolve this permission issue?
Answer
Problem Understanding
The error occurs because the application lacks the necessary Bluetooth privilege in the Tizen manifest file. This is a common issue when working with Bluetooth functionality in Tizen applications.
Solution Methods
-
Add the Bluetooth privilege to your tizen-manifest.xml file:
<privileges> <privilege>http://tizen.org/privilege/bluetooth</privilege> </privileges> -
Ensure your application requests the permission at runtime (for Tizen 4.0 and above):
int ret = privacy_privilege_manager_check_permission("http://tizen.org/privilege/bluetooth", &result); if (ret == PRIVACY_PRIVILEGE_MANAGER_ERROR_NONE) { if (result == PRIVACY_PRIVILEGE_MANAGER_CHECK_RESULT_ALLOW) { // Permission granted } else { // Request permission privacy_privilege_manager_request_permission("http://tizen.org/privilege/bluetooth", on_request_response, NULL); } }
Additional Tips
- Always verify that the privilege is correctly added to your manifest file before testing Bluetooth functionality
- For Tizen 4.0+, remember to handle runtime permission requests
- Double-check the privilege spelling in the manifest file
- After adding the privilege, clean and rebuild your project