Are there known issues with Android Services on 4.1.x (Jelly Bean)? -
my question shot in dark: deal android 4.x / jelly bean? there known problems services, stickiness, foreground, etc.?
backstory: tested music player application on sorts of android devices , emulators , on physical jelly bean device (samsung rugby pro). found mediaplayer
oncompletion
function not being fired consistently when screen turned off. isn't fired several minutes. when screen on, whether or not activity shown, application works fine.
(there no problems on gingerbread, kitkat, lollipop, or marshmallow. have physical devices versions , work flawlessly.)
device information:
- os version: 3.0.31-656355
- release: 4.1.1
- device: comancheatt
- model: samsung-sgh-i547
- product: comancheuc
- brand: samsung
- display: jro03l.i547ucbll1
- cpu_abi: armeabi-v7a
- cpu_abi2: armeabi
- hardware: qcom
- id: jro03l
- manufacturer: samsung
- user: se.infra
- host: sep-125
i figured out; hope helps ...
the problem not in firing oncompletion
event rather reset()
blocks indefinitely. had attributed android issue #959: mediaplayer "crash" (deadlocks calling thread) when resetting or releasing unused mediaplayer incorrect case.
my particular problem aggressive sleep behavior on test device. bug pop when ran in airplane mode few other apps because call reset()
(or release()
) releases mediaplayer
instance's wakelock
. once occurred device sleep , code appear block in function. unable reproduce debugger attached and/or plugged in because either of prevented device sleeping!
my solution create separately managed wakelock
acquire()
when playback begins , release()
after songs have played through. technically, when activity has been paused , release on resume because it's unnecessary hold wakelock
when device awake already.
powermanager powermanager = (powermanager) getsystemservice(power_service); wakelock wakelock = powermanager.newwakelock(powermanager.partial_wake_lock, "mytag"); wakelock.acquire();
Comments
Post a Comment