Android Question how to set power manager wake lock with the following rules

PassionDEV

Well-Known Member
Licensed User
in java, I can set the power manager to keep a socket connection alive like following

Java:
PowerManager.WakeLock newWakeLock = ((PowerManager) getSystemService("power")).newWakeLock(1, "Socket:WakeLock");

also with wifi
Java:
WifiManager.WifiLock createWifiLock = ((WifiManager) getApplicationContext().getSystemService("wifi")).createWifiLock(3, "Socket:WifiLock");

how can I achieve a similar approach in b4x?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
From my experience, such locks don't make any difference.
B4X:
Dim ctxt As JavaObject
ctxt.InitializeContext.RunMethodJO("getSystemService", Array("power")).RunMethod("newWakeLock", Array(1, "Socket:WakeLock"))
ctxt.RunMethodJO("getSystemService", Array("wifi")).RunMethod("createWifiLock", Array(3, "Socket:WifiLock"))
 
Upvote 0
Top