Android Question jRDC2 error : WakeLock already held

incendio

Well-Known Member
Licensed User
Longtime User
Hi guys,

I have two apps, App A & App B. App A & App B, have the same database server, but on a different database.
Upon exit, the apps record to database server, time, date, etc when user quit app.
Both App have the same codes to record this event
B4X:
Sub LogOut
    Private reqM As DBRequestManager
    If(reqM.IsInitialized = False) Then reqM.Initialize(Me, Main.PUB_SERVER)
    
    Private cmd As DBCommand
    cmd.Initialize   
    cmd.Name = "logout"
    cmd.Parameters = Array As Object(UserId, CurrentTime,CurrentDate)
    
    wait for (reqM.ExecuteCommand(cmd, "logout")) JobDone (job As HttpJob)
    Activity.Finish
End Sub

App A runs OK without a problems.

On App B, when running for the first time, after quit, on the log window in B4A there is a message
sending message to waiting queue (CallSubDelayed - JobDone)

but App B can quit without a problem, but when running App B for the second time, after users tried to login to App B, the App just quit, won't start.
On log windows, there are an error messages
WakeLock already held
running waiting messages (1)


So, what's wrong with App B?
 

DonManfred

Expert
Licensed User
Longtime User
So, what's wrong with App B?
We don´t know as you are not providing enough Informations.

The problem can be app a or b.
You probablky use any wakelock in a service. But not releasing it. the other app then do the same but the lock is already set.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

incendio

Well-Known Member
Licensed User
Longtime User
You should use CreateRequest from the tutorial: https://www.b4x.com/android/forum/t...ation-of-rdc-remote-database-connector.61801/


These are not errors.

However you should move LogOut to the Starter service.
App A & App B were an old Apps, so your method were not implemented yet.

App A was created almost 2 years ago and runs OK, so when App B made, I copied some of codes that works fine from App A to App B.

After I implemented your suggestion, App B works fine, but on App A, still using 'old' method and Sub Logout was not on Starter Service, after recompiled it with latest B4A, it was runs OK.

I wonder why on App A, same codes didn't give problem?

Codes on Starter service on both Apps something like these
B4X:
Sub Service_Create
    Private rtp As RuntimePermissions
    Main.PUB_InstDir= rtp.GetSafeDirDefaultExternal("")
End Sub

Sub Service_Start (StartingIntent As Intent)
    Main.SQLMem.Initialize("", ":memory:", True)
    Main.SQLMem.ExecNonQuery("create table MEM_MENU(LVL int,IDPRVMN int,MENU text,DSCP text,VAL text)")
    Main.kvs.Initialize(Main.PUB_InstDir, "datastore")
End Sub
 
Upvote 0
Top