android - How can I prevent OS to kill my MUSIC app (use MediaPlayer, service)? -
i using service in music application , needs run until application detroyed, problem gets killed os(my phone run android 4.2.2, , have 128mb of ram).so os alway kill app service when pess home button or button.
i have searched on stackoverflow , tryed solution:
@override public int onstartcommand(intent intent, int flags, int startid) { notify("service startcommanded"); myplayer.start(); return start_sticky; }
but music restart begin position, done want happen ps: i'm vietnamese,so don't english.soory this,but don't have solution vietnam forums. alot
granted service gets new intent every song tries play try use redeliver intent flag.
http://developer.android.com/reference/android/app/service.html#start_flag_redelivery
keep in mind won't make service restart in same start sticky, there maximum number of times tries restart it.
in ondestroy find out in music play back, store value , seek position when start playback again.
finally, if you're getting killed fast system, may need optimize memory consumption inside of service.
Comments
Post a Comment