0

In my FirebaseMessagingService, I want to use interface because whenever I get notification, I want to do some operation in my activity. So is it possible to use Interface in FirebaseMessagingService?

KENdi
  • 7,576
  • 2
  • 16
  • 31
Geeta Gupta
  • 1,622
  • 11
  • 17
  • There is no way to trigger an operation on an Activity when something happens at a Service. That's because Services are designed to work in the background. Your activity might not be visible when the service triggers the operation and that would generate an error. May I ask: What kind of operation are you trying to do in your activity when a new notification arrives? – Rosário Pereira Fernandes May 15 '18 at 19:17
  • Also: Should this operation happen only when the activity is visible? And not happen when the activity is invisible? – Rosário Pereira Fernandes May 15 '18 at 19:18

1 Answers1

0

Probably thats the only way. Create a Broadcast receiver and feel free to comunicate with your notifications

https://stackoverflow.com/a/41931325/8383365

rosinek
  • 23
  • 3