Android Question HMS (Huawei) - DRM verification - drmcallback_event ignored

CaptKronos

Active Member
Licensed User
Longtime User
Using the tutorial here, the following works in that I get the dialog box about the app not being purchased. Also, adding the drm test account and rerunning the code, the dialog is not shown. So all good.
B4X:
Wait For (hms.CheckDRM(Main.DRM_ID, Main.DRM_KEY)) Complete (Success As Boolean)
If Success = False Then
    Log("Not purchased")
    'ExitApplication
End If

However, the Wait For never returns (the "Not purchased" is not logged) and the Logs displays:
Ignoring event: drmcallback_event

I'm testing on a real device, in both Debug and Release modes.
 

CaptKronos

Active Member
Licensed User
Longtime User
No, it's just a regular "default" project.
B4X:
Sub Activity_Create(FirstTime As Boolean)
    hms.Initialize
    hms.EnableLogs
    Activity.LoadLayout("Layout")
End Sub

Sub Button1_Click
    Wait For (hms.CheckDRM(DRM_ID, DRM_KEY)) Complete (Success As Boolean)
    If Success = False Then
        Log("Not purchased")
        'ExitApplication
    Else
        Log("purchased")
    End If
End Sub
 
Last edited:
Upvote 0

CaptKronos

Active Member
Licensed User
Longtime User
Thanks, a B4XPages test project works. However, my existing application that I would like to get to work with the DRM system was created before B4XPages existed. Is it possible to get DRM working with a regular project?
 
Upvote 0

CaptKronos

Active Member
Licensed User
Longtime User
I had a look at the B4XPages code and the following seems to be the relevant part to make the DRM work. It might be a bit hacky but it seems to work for me. After my code receives drmcallback_event, I set the dontPause setting back to false.
B4X:
    Dim jo As JavaObject = Me
    Dim module As JavaObject
    module.InitializeStatic(jo.RunMethodJO("getActivityBA", Null).GetField("className")).SetField("dontPause", True)
 
Upvote 0
Top