http://startandroid.ru/ru/uroki/vse-uroki-spiskom/159-urok-94-service-podrobno-pro-onstartcommand.html

In this lesson, written in 2012, the author creates a service in a separate project. Creates another project with activation. Sends an intent with Action and sets up an intent filter service. And first he installs a service in the emulator. it is installed, but its process does not start. Puts a project with activation, presses a button, transfers the intent and the service starts, a service process appears. But now it does not work for me, when I install the service I see in the log

I/ActivityManager: Force stopping startandroid.servicebindserver appid=10064 user=0: from pid 3592 

What does this string mean? I understand that this service is killed immediately, but I didn’t ask to launch it. Well, naturally, when I launch the application and try to send an intent to start the service, I get an error. the log says that the intent should be explicit. but I want implicit, via Action. If my question is not related to changes in android and the error may be somewhere in my code, then I will attach the code with the log, but I think that something has changed in android.

  • all articles older than 2016 safely ignore - Sviat Volkov
  • I doubt the fidelity of your comment - Turalllb
  • I realized that on android above 4 it is impossible to transfer implicit intent to startService (). So you can’t use the action to call the service anymore? - Turalllb
  • one
    only system applications can do this, or at least root rights are needed. service start without activity is impossible. - Sergey
  • with the root using the terminal, you can put jar and java.class into the service independently of nothing, similar to linux systems. And in that example, there is nothing unusual. - Sergey

2 answers 2

In general, as far as I understand, for security purposes, a service can only be started with activation. True, I could be wrong. If you just need a service without activation, then it is done like this.

 Intent intent = new Intent(Service.class, this); startService(intent); this.finish(); 

This is all registered in the MainActivity and it closes immediately after launch. But for some reason it seems to me that I misunderstood you)

  • Well, the service is needed without activating, what's the point in registering something in mainActivity - McDaggen
  • Andrei Bespalov, so I need not that, as you understand) In the lessons, it is clearly written that a project is being created without a single activation, there is one service in the project. And it is installed in the phone. The lesson also says that this service itself will not start after installation, as an application would have done with activation. This is just for security reasons. And then through a third-party application through an implicit call, I can enable this service. But it does not work. The log is written, use an explicit call. And I need to know about the implicit. Whether it rolls or since when does not roll - Turalllb
  • McDaggen, there must be two projects. In one service without activating and configured intent filter. And in the second, an implicit call is made in the activation using the action specified in the service project - Turalllb

After some update, you cannot use the action to call the service. See for security reasons have closed this opportunity. Now you need to specifically know that such a service is installed and its package such.