public class ChirpBrowser
extends java.lang.Object
ChirpBrowser is used to listen for Chirp services on the local network. You can
construct and start a browser manually, or use the simpler class builder, like so:
ChirpBrowser browser = Chirp.browseFor("com.example.service").
listener(this).
start(getApplication());
When you no longer need to listen for service(s) you should stop the browser:
browser.stop();
| Modifier and Type | Class and Description |
|---|---|
static class |
ChirpBrowser.Builder
Used to chain configuration calls for creating a
ChirpBrowser. |
| Constructor and Description |
|---|
ChirpBrowser(java.lang.String serviceName)
Creates a browser that can search for the specified service name.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
isStarted()
Returns true if the browser is listening for services.
|
void |
setListener(ChirpBrowserListener l)
Sets a listener to receive callbacks.
|
void |
start(Application app)
Starts listening for and reporting Chirp service(s) on the local network.
|
void |
stop()
Stops the browser from listening and reporting services.
|
public ChirpBrowser(@NonNull
java.lang.String serviceName)
Chirp.browseFor(String) to create and configure a ChirpBrowser
instead of using the constructor.serviceName - a valid service name, or "*" if the browser should return all services
on the networkpublic boolean isStarted()
public void setListener(ChirpBrowserListener l)
l - a ChirpBrowserListener or nullpublic void start(@NonNull
Application app)
app - the Application object is requested instead of a Context
to avoid memory leaks from an Activity being passed inpublic void stop()
ChirpBrowser can
not be reused.