Alex
Alex

Reputation: 3821

Starting a *newly* installed app/service from another app

I want to be able to start my service right after installing it from a .apk but per this post, it seems like it is not possible. Given the nature of the project I am working with, the alternative solution is to have an app that can be remotely triggered to start the newly installed service. Would this work without root privileges? In other words, is the only way to start a newly installed app (from .apk) to start it manually?

Thanks

Upvotes: 0

Views: 39

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006674

In other words, is the only way to start a newly installed app (from .apk) to start it manually?

For some definition of "manually", yes.

An app that is newly installed is in the so-called "stopped state". Until something uses an explicit Intent to communicate with one of its components, nothing of that app will run, such as manifest-registered receivers.

Typically, this is handled by the user tapping on a home screen launcher icon. However, there are other scenarios. For example, in a host-and-plugin situation, the host could be monitoring ACTION_PACKAGE_ADDED broadcasts, to see if a plugin was installed. The host can then use an explicit Intent to initiate communications with the plugin (e.g., send a command to a service exposed by the plugin). At that point, the plugin will behave like a normal app.

the alternative solution is to have an app that can be remotely triggered to start the newly installed service

That strikes me as having some possible security issues, but yes, you could tell App A via some network event "Yo! App B is now installed! Go use some explicit Intent to talk to it!".

Would this work without root privileges?

Yes.

Upvotes: 1

Related Questions