android:persistent="true" to stop my service from being killed not working

6,513 views
Skip to first unread message

James

unread,
Dec 16, 2010, 10:53:54 PM12/16/10
to android-platform
Hey all,

I've added android:persistent="true" to the application tag of my
AndroidManifest.xml file because I kept seeing my service restarted
and it needs to up as long as the phone is alive. I've marked it as
persistent (like the Phone app) but I'm still able to kill it in the
Settings -> Applications -> Running Services activity and android
still restarts it every once in a while. I read a post from Dianne
Hackborn from a while back that said that this only works if you're
building a custom framework (which I am) and to look at the Phone app
as an example. I don't see anything special in the phone app besides
that tag in its manifest. I noticed that its signed with the platform
certificate...is this required for the persistent attribute to be
honored?

Thanks,
James

Dianne Hackborn

unread,
Dec 19, 2010, 1:27:19 AM12/19/10
to android-...@googlegroups.com
Use "adb shell dumpsys activity" to see the state of your process and verify that it is actually persistent.

Look at logs during boot, with any error messages about problems there may be making it persistent.


--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To post to this group, send email to android-...@googlegroups.com.
To unsubscribe from this group, send email to android-platfo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-platform?hl=en.




--
Dianne Hackborn
Android framework engineer
hac...@android.com

Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails.  All such questions should be posted on public forums, where I and others can see and answer them.

James

unread,
Dec 20, 2010, 2:44:32 PM12/20/10
to android-platform
Thanks Dianne,

Doesnt look like my app is being labelled PERS in the "adb shell
dumpsys activity". I'm only seeing the following as PERS:

PERS #14: adj=sys /F 43e3be50 64:system/1000 (fixed)
PERS #10: adj=core /F 43f1b660 132:com.android.phone/1001 (fixed)

Mine looks like this:

App #12: adj=svc /B 43f6dee0 269:com.test.testpersistence/10032
(started-services)

There are no errors in logcat on boot related to persistence.

Is signing the apk with the platform key required to achieve
persistence?
> > android-platfo...@googlegroups.com<android-platform%2Bunsu...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/android-platform?hl=en.
>
> --
> Dianne Hackborn
> Android framework engineer
> hack...@android.com

Dianne Hackborn

unread,
Dec 20, 2010, 6:06:43 PM12/20/10
to android-...@googlegroups.com
No you do not need to sign with a platform key.  You just need to be in /system/apps.

You could try putting a log in PackageParser.java where it checks for AndroidManifestApplication_persistent.


To unsubscribe from this group, send email to android-platfo...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/android-platform?hl=en.




--
Dianne Hackborn
Android framework engineer
Reply all
Reply to author
Forward
0 new messages