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

后端 未结 10 1623
遇见更好的自我
遇见更好的自我 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:23

    I'm not sure what your constraints/purpose is, but if you can install another application that has an activity you can have it send an intent with the flag FLAG_INCLUDE_STOPPED_PACKAGES.

    This will use your application for the intent resolution, even though it's in a stopped state. If the action of the intent matches one of your filters, it will also bring the package out of the stopped state.

提交回复
热议问题