0

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

Community
  • 1
  • 1
Alex
  • 3,441
  • 4
  • 18
  • 30

1 Answers1

1

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.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Thanks for that, first of all: in tour host and plugin example, is the host another service running on the phone? Also, what security issues do you foresee using the service to remotely start and app? – Alex Jun 18 '15 at 00:58
  • @lpbug: "is the host another service running on the phone?" -- it's an app installed on the phone. AFAIK, you can register for `ACTION_PACKAGE_ADDED` broadcasts in the manifest, so the app would not have to be running. For your remote trigger, whether or not the app has to be running depends upon your communications approach (e.g., GCM vs. WebSocket vs. ...). "what security issues do you foresee" -- somebody sending fake triggers, for starters. – CommonsWare Jun 18 '15 at 11:07