and a service module named PowerConnectedReceiver,
B4X:
Sub Service_Start (StartingIntent As Intent)
Log("Power Connected!")
Service.StopAutomaticForeground 'Call this when the background task completes (if there is one)
End Sub
I have a simple Android Kotlin app, and part of what it does is listen for when power is connected and disconnected and perform an action This is my old code, and it worked totally fine while targ...
Would the Battery_Changed event of the PhoneEvents library not suffice?
B4X:
Sub Process_Globals
'...
Private pe As PhoneEvents
'...
End Sub
Sub Service_Create
'...
pe.Initialize("pe")
'...
End Sub
Sub pe_BatteryChanged (Level As Int, Scale As Int, Plugged As Boolean, Intent As Intent)
Log(Plugged)
End Sub
Thank you @DonManfred, you pointed me to the right direction, now I just changed the targetSdkVersion to "25", and it works! @OliverA, because I want to catch power connected and power disconnected events.