lundi 2 mars 2020

How to communicate between library and app in Java Android?

Suppose the following scenario:

Class S is part of an SDK or Library being used by many custom apps.
Class A is part of one app which employs the SDK.
Class S contains a server response variable I want to send over to Class A, as soon as it lands, for further processing (some logs and analytics). Class A is the only one capable of doing this job.

The premises are that apps using the SDK can access its classes, but not viceversa.
So class S cannot use anything related to class A.

Question:
How can I achieve this?

The language I am writing in is Java.
I have tried implementing an Observer pattern, but I don't think it's what I am after. It's probably a callback mechanism that will sort this out for me, but I cannot seem to pinpoint it.

Aucun commentaire:

Enregistrer un commentaire