Health Connect Permission Revocation Edge Case
Understanding Health Connect Permission Revocation
When calling ValidicHealthConnect.disconnect, you may encounter an exception related to permission revocation. This is a known edge case with the Health Connect platform's permission handling system.
Understanding the Issue
Example error: IllegalArgumentException: Cannot revoke permission android.permission.health.READ_HEALTH_DATA_IN_BACKGROUND for package com.package.app since android.permission.health.READ_HEALTH_DATA_IN_BACKGROUND does not belong to a permission group
Important Notes
This is a Health Connect platform behavior, not an SDK implementation issue
The error is non-critical and does not prevent the disconnect operation from completing successfully
The Health Connect session will still end properly even if permission revocation encounters this exception
Best Practice Implementation
Always wrap Health Connect disconnect calls in try-catch blocks:
try {
ValidicHealthConnect.disconnect(revokePermissions = true)
} catch(e:Exception){
Log.e("Error", e.message)
}
Additional Technical Details
The Health Connect revokeAllPermissions() operation can throw several types of exceptions:
RemoteException - For IPC transportation failures
IOException - For disk I/O issues
IllegalStateException - If service is not available
Implementation Recommendations
Always implement error handling around disconnect operations
Log permission revocation failures for debugging purposes
Allow your app to continue functioning even if permission revocation fails
No special error recovery is needed beyond basic exception-catching and logging
For any questions or additional support, please contact Validic Support at support@validic.com.