0

In my application I have two Services. One is

 public AndroidUpnpService upnpService;

which is from the Cling Library and scans the WLAN for other UPnP devices.

I am binding it like this

 getApplicationContext().bindService(
            new Intent(this, AndroidUpnpServiceImpl.class),
            serviceConnection,
            Context.BIND_AUTO_CREATE
    );

and everything works fine.

As soon as I bind a BeaconManager like this though

beaconManager = BeaconManager.getInstanceForApplication(this);
beaconManager.bind(this);

my UPnPService is no longer able to detect other devices.

I only get error messages like the following

W/StreamClient﹕ HTTP connection failed: (StreamRequestMessage) GET http://192.168.178.27:53447/upnp/dev/{some address}/desc
libcore.io.ErrnoException: isConnected failed: EHOSTUNREACH (No route to host)
        at libcore.io.IoBridge.isConnected(IoBridge.java:208)
        at libcore.io.IoBridge.connectErrno(IoBridge.java:161)
        at libcore.io.IoBridge.connect(IoBridge.java:112)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
        at java.net.Socket.connect(Socket.java:843)
        at java.nio.SocketChannelImpl$SocketAdapter.connect(SocketChannelImpl.java:532)
        at org.eclipse.jetty.client.SelectConnector.startConnection(SelectConnector.java:79)
        at org.eclipse.jetty.client.HttpDestination.startNewConnection(HttpDestination.java:275)
        at org.eclipse.jetty.client.HttpDestination.doSend(HttpDestination.java:566)
        at org.eclipse.jetty.client.HttpDestination.send(HttpDestination.java:504)
        at org.eclipse.jetty.client.HttpClient.send(HttpClient.java:165)
        at org.fourthline.cling.transport.impl.jetty.StreamClientImpl$2.call(StreamClientImpl.java:114)
        at org.fourthline.cling.transport.impl.jetty.StreamClientImpl$2.call(StreamClientImpl.java:108)
        at java.util.concurrent.FutureTask.run(FutureTask.java:237)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
        at java.lang.Thread.run(Thread.java:841)

Is there a specific way I have to set this up to get both things running in one application? I have already tried setting

beaconManager.setBackgroundScanPeriod(10000l);

so it only scans every 10 seconds which is totally fine for what I want to do but it still does not work.

b-m-f
  • 1,278
  • 2
  • 13
  • 29

1 Answers1

0

Setting

beaconManager.setForegroundBetweenScanPeriod(10000l);

solves this.

setForegroundScanPeriod/setBackgroundScanPeriod just prolongs the time that a scan for beacons will take.

b-m-f
  • 1,278
  • 2
  • 13
  • 29