Back to project page Kite.
The source code is released under:
Apache License
If you think the Android project Kite listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/**<h1>Wire is up to simplify connecting to local {@link android.app.Service}s.</h1> * <br/>/*from w w w . j a v a2s. c o m*/ * Connecting to local services ( that are in same process as their clients) * using binding mechanism, and by default will also fill dependencies in client. * <br/> * <pre> public class MyService extends WiredService { @Provided WorkerInterface worker = new WorkerImpl(); } // it can be Activity, Fragment or any object // what you need, is Context public class MyClient { @Wired WorkerInterface serviceWorker; // init wire = new Wire(context).from(MyService.class).to(this); // onStart(): wire.connect(); // serviceWorker will be filled with WorkerImpl instance from // service // onStop(): wire.disconnect(); // serviceWorker will be nullified } * </pre> * <p>Scopes</p> * By default, when you connect pointing service class, * you get all provided instances with ALL scope. * So if you want to adhere encapsulation, you can set scope provided instances: * <br/> * <pre> // will be available only when intent.action == SOME_INTENT_ACTION @Provided(scope = Scope.ACTION, action = SOME_INTENT_ACTION ) SomeInterface worker; // will be available with any intent and with no intent @Provided(scope = Scope.ALL ) SomeInterface worker; // default, will be available only when no intent is set in connection @Provided(scope = Scope.DEFAULT) SomeInterface worker; * </pre> * * @author Nikolay Soroka */ package org.kite.wire;