Anti-patterns (Common Mistakes)
Generating JWT URLs directly inside a mobile app
Anti-pattern
Implementing JWT signing logic that contains a security key directly in the mobile client app (Android) source code
- Problem: The security key may be leaked externally, creating a serious security vulnerability.
- Correct approach: JWT must be issued from the customer's server and then delivered to the mobile app.
Misusing the unload(mck) method to pause downloads
Anti-pattern
Calling the unload method to temporarily pause a content download
- Problem:
unloadcancels the download, so when the download is resumed, it starts over from the beginning. - Correct approach: If partial resume (continuation) functionality is required, track the progress state separately and verify the SDK's resume behavior directly.
Automatically re-downloading the entire file when DRM-expired content is played
Anti-pattern
Implementing a re-download of the video file itself when a DRM license has expired
- Problem: Unnecessary network traffic is generated and the user's download wait time increases.
- Correct approach: Without re-downloading the video file, simply call the
updateDownloadDRMInfomethod to renew only the DRM license. For more details, refer to the 6. DRM License Renewal document.
Missing FOREGROUND_SERVICE_TYPE_DATA_SYNC on Android 10 (API 29) and above
Anti-pattern
Targeting Android 10 or higher without specifying a foreground service type for the background download service
- Problem: When the app moves to the background during a download, a
SecurityExceptionis thrown and the download is forcibly stopped. - Correct approach: When calling
startForeground(), explicitly specify the foreground type, and also add the type to the service declaration inAndroidManifest.xmlas shown below. For more details, refer to the 1. Download Preparation document.
Failing to register and unregister callback listeners
Anti-pattern
Not pairing the registration and unregistration of callback listeners with the lifecycle of an Activity or Service
- Problem: Memory leaks may occur, or callbacks may be delivered to an already-destroyed component, causing the app to crash.
- Correct approach: If
register*Listeneris called inonCreate()to match the lifecycle,unregister*Listenermust always be called inonDestroy()to unregister it.
Starting a content download without checking available storage
Anti-pattern
Starting a large content download without checking the remaining storage space on the user's device
- Problem: If storage becomes full during the download, the download fails with an
ERROR_WRITE_FILEerror. - Correct approach: Before starting a download, it is recommended to verify that the value of
Utils.getAvailableMemorySize(path)is greater than or equal to the sum of the content file size and the minimum required free space.
Directly setting download progress with setDownloadPercent
Anti-pattern
Directly calling Setter methods such as KollusContent.setDownloadPercent() from app code to forcibly change the progress value
- Problem: This method is an internal-use method intended for processing data within the SDK's internal callback flow. Modifying it externally breaks SDK data consistency and can cause malfunctions.
- Correct approach: Download progress should only be transmitted and displayed using values received through the official callback listeners provided by the SDK, and must not be modified directly from the app.