简体   繁体   中英

Auto start of a Service of a System app in Android

I want to initiate a system app service without opening the service app even once. It should run once its installed. I know how to add a boot receiver and restart the service on reboot of the phone. I would like to know how to make the service start when the application is installed.

这是不可能的,您的用户必须至少打开一次应用程序才能启动您编写的任何代码。

您无法执行此操作,这是Rogue软件的行为,在android 4.0之后,如果您的应用程序从未启动过,即使BroadcastReceiver也无法正常工作,则用户必须至少启动一次

you have to create one activity file. And when you run first time the application Android os will provide the PID. And Android os only send broadcast to who have the PID. To run service without interface you have to give any broadcast. For example boot completion. But order to get broadcast from os you need PID. And for PID you have to lunch your application at list once with activity class.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM