How to start a Service when .apk is Installed for the first time

后端 未结 10 1617
遇见更好的自我
遇见更好的自我 2020-11-22 10:33

In my Application I am not having any UI part, so I need to start a Service as soon as the Applicaton gets installed on the Device. I saw many links from which the answer wa

10条回答
  •  伪装坚强ぢ
    2020-11-22 11:10

    Applications installed on the /system partition are not subject to being placed into the "stopped" state after installation. If you have root, you can do,

    $ adb root
    $ adb remount
    $ adb push your.apk /system/app
    

    And it can immediately receive broadcast intents. This certainly doesn't provide a general purpose solution, but i wanted to mention it for completeness.

    EDIT: Keep in mind that different versions of Android locate system APKs in different places. For example, Android 8 puts them under /system/app//.apk. Shell into your device and poke around and follow the same scheme used for other system APKs.

提交回复
热议问题