0

This IS NOT A DUPLICATE of this question.

I either do not clearly understand how serivces work, or it's indeed not what I need. I want the service to process events, must it still be started? If so, why is it implicitly started when activity is defined? I don't want long running operation, I want event handling. As far as I understand, intent-filter notifies Android that service should be called, if condition is met, i.e. push message is received. This question somewhat confirms the assumption.

When I have an activity in my app service gets fired whenever message arrives:

<service android:name=".FbMessagingService">
    <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT"/>
    </intent-filter>
</service>

But as soon as I comment out the activty in manifest, neither breakpoint is hit nor logcat show any messages. So I assume service is kind of not registerd... Is activity a MUST?

Pavel Voronin
  • 13,503
  • 7
  • 71
  • 137
  • @NileshRathod Sure, I've seen this question. But I either do not clearly understand how serivces work, or it's indeed not what I need. I want the service to proccess events, must it still be started? If so, why is it implicitly started when activity is defined? I don't want long running operation, I want event handling. As far as I understand, intent-filer notifiest Android that service should be called if condition is met, i.e. push message is received. – Pavel Voronin Mar 30 '18 at 13:09
  • 1
    Why not use `BroadcastReceiver`s? – F43nd1r Mar 30 '18 at 13:16
  • @F43nd1r Will have a look at it, thanks. I am new to Android. Still want to anderstand all this stuff with intent-filters. – Pavel Voronin Mar 30 '18 at 13:17

0 Answers0