-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
External Service Bind Use Case #91
Labels
Comments
|
Oke thank u
…On Tue, Sep 3, 2024 at 7:25 AM ljluestc ***@***.***> wrote:
public class ExternalServiceBinder {
private Context context;
private IExternalService externalService;
private ServiceConnection serviceConnection;
public ExternalServiceBinder(Context context) {
this.context = context;
this.serviceConnection = new ServiceConnection() {
@OverRide
public void onServiceConnected(ComponentName name, IBinder service) {
externalService = IExternalService.Stub.asInterface(service);
// Notify listeners or perform actions after service is connected
}
@OverRide
public void onServiceDisconnected(ComponentName name) {
externalService = null;
// Handle disconnection
}
};
}
public void bindService() {
Intent intent = new Intent(context, ExternalService.class);
context.bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE);
}
public void unbindService() {
context.unbindService(serviceConnection);
}
public IExternalService getService() {
return externalService;
}
}
—
Reply to this email directly, view it on GitHub
<#91 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA5BK6J3TD5U362NJF4ZKQTZUT6Y7AVCNFSM6AAAAABNRBSSOGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMRVGQYTAMZSGI>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi guys, i'm trying to implement the clean architecture into a big Android enterprise project since it fits perfectly in our needs. The only obscure thing it's about bind/unbind to external service (which expose an API trough AIDL). My question is: where the bind/unbind calls goes?
Our external services acts like a repository (method call -> callback with result) but it could push some data to the app occasionally (callback only).
So, in the use case where we pull data from service, this could fit into the data layer... about the second use case, when the service needs to push data, this goes in the data layer as well since some obeservable could notify about the changes to the service data (we use a memory cache which, once updated, notify about the new state).
In any way, for both to work this way, we need to bind to the external service interface: it's right to write use cases to handle this scenarios (like (un)registerForDataUpdates)?
The text was updated successfully, but these errors were encountered: