I am developing an ebook reader
as an android app. But I want the downloaded ebook files (eg. epub) to be DRM protected. I referred to the links mentioned below and tried to implement it but resulted with an error. I am at very beginning level of implementing DRM.
My Code:
DrmManagerClient drmManagerClient = new DrmManagerClient(getApplicationContext());
DrmInfoRequest drmInfoRequest = new DrmInfoRequest(0, "text/plain"); //<--- Error in this line
DrmInfo drmInfo = drmManagerClient.acquireDrmInfo(drmInfoRequest);
Log.e("sth...: ", drmInfo.getInfoType() + "");
Error:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.user.androiddrm/com.example.user.androiddrm.MainActivity}: java.lang.IllegalArgumentException: infoType: 0,mimeType: text/plain
The basic code above is implemented based on the following documentation:
https://developer.android.com/reference/android/drm/package-summary.html
https://developer.android.com/reference/android/drm/DrmInfoRequest.html
Now the Link 4 explains about drm but using MediaPlayer
as example but mine is for epub files. Even though the implementation of acquireDrmInfo()
is different as followed to the above 3 links.
This link specifically targets for media player Exoplayer
, so not much of help.
Note: After the epub file is downloaded, the user should be able to read offline so I don't think there will be any online activity.
So how to fix above error and is there any better tutorials on using Android.Drm Framework?