I have done some more testing keeping the app running overnight.
- in the manifest: <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="23"/>
- a service running as Service.StartForeground
- the first line in Service_Start is WakeState.PartialLock
- the last line in Service_Start is WakeState.ReleasePartialLock
- the service reschedules itself using Erel's code:
Dim p As Phone
If p.SdkVersion < 23 Then
StartServiceAtExact("", RestartAt, True)
Else
Dim in As Intent
in.Initialize("", "")
in.SetComponent(Application.PackageName & "/.monitor")
Dim ctxt As JavaObject
ctxt.InitializeContext
Dim am As JavaObject = ctxt.RunMethod("getSystemService", Array("alarm"))
Dim pi As JavaObject
pi = pi.InitializeStatic("android.app.PendingIntent").RunMethod("getService", _
Array(ctxt, 1, in, 134217728))
am.RunMethod("setExactAndAllowWhileIdle", Array(0, RestartAt, pi))
End If
the service is supposed to run once a second when the screen is on and once a minute when the screen is off
-when the screen is on, running the service is limited to once every 5 seconds
-when the screen is off, the first hour, all runs as normal
-when "doze" starts, the service is running once every 9 minutes
As far as I can see, this is the behavior as intended by google.
In order to test this, I made the service as such that, each time the service runs, a message is sended to a server because when connecting the phone to the computer and looking at the log switches off Doze....