Hanging UI thread on Android

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

Hanging UI thread on Android

Gyuri
I followed the examples for binding the service,using the service connection, etc. In my Activity's onCreate I call bindService and that returns right away. The problem is that the UI thread seems to hang until onServiceConnected is called. This means the user is looking at a blank screen while this happens.

Is Cling threaded? Anything I need to do so that it doesn't block the UI thread?

Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: Hanging UI thread on Android

Christian Bauer
Administrator
Your question is probably "is Cling startup multithreaded" and the answer is No. The AndroidUpnpServiceImpl#onCreate() method will need a few (hundred) milliseconds before the service is ready.

This is really an Android question. You "bind" and then asynchronously some thread will create the service instance and call its onCreate() method. I'm not sure if there is even controls for this behavior, you should look into what/how threads are created for service binding. If indeed the UI thread is used then that would block and I'd call that a bug in Android.

I have not seen a blocking UI though. My guess is that you are just experiencing UI lag and not a block, on a slow device.
Reply | Threaded
Open this post in threaded view
|

Re: Hanging UI thread on Android

Gyuri
Christian,
Thanks for your reply. I've investigated further. I now delay the binding so that the activity can show up. I'm still seeing a relatively consistent 10 second delay between bindService and getting the onServiceConnected callback, during which the UI thread hangs (and I can cause an ANR if I tap around the unresponsive screen). I've taken some logs, first from a stock Droid, second from a stock Nexus One. Both show the same behavior; approximately 10 seconds from binding to service connected callback. My next step would be to debug into Cling to see what's happening in the binding process, so I'm just wondering if anything jumps out at you from the logs.

From Droid:

02-17 10:42:14.327: DEBUG/****/DirectorActivity.java:87(9096): 10:42:14.323 main binding service
02-17 10:42:14.475: INFO/UpnpServiceImpl(9096): >>> Starting UPnP service...
02-17 10:42:14.475: INFO/UpnpServiceImpl(9096): Using configuration: ****.upnp.****UpnpService$1
02-17 10:42:14.624: DEBUG/dalvikvm(9096): GC_FOR_MALLOC freed 9228 objects / 398336 bytes in 74ms
02-17 10:42:14.631: INFO/dalvikvm(9096): Could not find method java.net.NetworkInterface.isLoopback, referenced from method org.teleal.cling.model.ModelUtil.getFirstNetworkInterfaceHardwareAddress
02-17 10:42:14.631: WARN/dalvikvm(9096): VFY: unable to resolve virtual method 3488: Ljava/net/NetworkInterface;.isLoopback ()Z
02-17 10:42:14.631: DEBUG/dalvikvm(9096): VFY: replacing opcode 0x6e at 0x0018
02-17 10:42:14.631: DEBUG/dalvikvm(9096): VFY: dead code 0x001b-002e in Lorg/teleal/cling/model/ModelUtil;.getFirstNetworkInterfaceHardwareAddress ()[B
02-17 10:42:14.725: INFO/UpnpServiceImpl(9096): <<< UPnP service started successfully
02-17 10:42:14.811: INFO/Router(9096): WiFi state changed, enabling router
02-17 10:42:14.811: INFO/Router(9096): Creating Router: org.teleal.cling.transport.RouterImpl
02-17 10:42:14.866: INFO/NetworkAddressFactory(9096): Discovered WiFi network interface: tiwlan0
02-17 10:42:19.764: DEBUG/dalvikvm(8825): GC_EXPLICIT freed 91 objects / 8200 bytes in 71ms
02-17 10:42:24.780: DEBUG/dalvikvm(8833): GC_EXPLICIT freed 210 objects / 13264 bytes in 86ms
02-17 10:42:25.085: INFO/StreamServer(9096): Created socket (for receiving TCP streams) on: 192.168.128.20/192.168.128.20:46036
02-17 10:42:25.100: INFO/MulticastReceiver(9096): Creating wildcard socket (for receiving multicast datagrams) on port: 1900
02-17 10:42:25.131: INFO/MulticastReceiver(9096): Joining multicast group: 239.255.255.250/239.255.255.250:1900 on network interface: tiwlan0
02-17 10:42:25.131: INFO/OSNetworkSystem(9096): mcastAddDropMembership interfaceIndex=9
02-17 10:42:25.139: INFO/DatagramIO(9096): Creating bound socket (for datagram input/output) on: 192.168.128.20/192.168.128.20
02-17 10:42:25.186: DEBUG/****/DirectorActivity.java:128(9096): 10:42:25.176 main ServiceConnection.onServiceConnected

From Nexus One:

02-17 10:52:58.002: DEBUG/****/DirectorActivity.java:87(5718): 10:52:58.001 main binding service
02-17 10:52:58.012: INFO/UpnpServiceImpl(5718): >>> Starting UPnP service...
02-17 10:52:58.022: INFO/UpnpServiceImpl(5718): Using configuration: ****.upnp.****UpnpService$1
02-17 10:52:58.042: INFO/UpnpServiceImpl(5718): <<< UPnP service started successfully
02-17 10:52:58.052: INFO/Router(5718): WiFi state changed, enabling router
02-17 10:52:58.052: INFO/Router(5718): Creating Router: org.teleal.cling.transport.RouterImpl
02-17 10:52:58.052: INFO/NetworkAddressFactory(5718): Discovered WiFi network interface: eth0
02-17 10:52:58.692: DEBUG/LocationMasfClient(85): getNetworkLocation(): Returning cache location with accuracy 58.0
02-17 10:52:58.702: DEBUG/RC_WifiBroadcastReceiver(4905):  action android.net.wifi.SCAN_RESULTS
02-17 10:52:58.742: DEBUG/RC_WifiService(4905): notifyScanResults() 590391022
02-17 10:53:00.232: DEBUG/dalvikvm(5946): GC_FOR_MALLOC freed 6417 objects / 381192 bytes in 63ms
02-17 10:53:00.272: DEBUG/dalvikvm(5946): GC_FOR_MALLOC freed 1006 objects / 107936 bytes in 31ms
02-17 10:53:00.272: INFO/dalvikvm-heap(5946): Grow heap (frag case) to 3.734MB for 310366-byte allocation
02-17 10:53:00.322: DEBUG/dalvikvm(5946): GC_FOR_MALLOC freed 0 objects / 0 bytes in 44ms
02-17 10:53:00.352: DEBUG/dalvikvm(5946): GC_FOR_MALLOC freed 255 objects / 350104 bytes in 31ms
02-17 10:53:00.712: INFO/dalvikvm(5946): Jit: resizing JitTable from 4096 to 8192
02-17 10:53:00.782: DEBUG/dalvikvm(5946): GC_FOR_MALLOC freed 4434 objects / 169880 bytes in 36ms
02-17 10:53:04.112: DEBUG/dalvikvm(5946): GC_FOR_MALLOC freed 8485 objects / 690568 bytes in 48ms
02-17 10:53:05.842: DEBUG/dalvikvm(12176): GC_EXPLICIT freed 7821 objects / 442128 bytes in 49ms
02-17 10:53:08.072: INFO/StreamServer(5718): Created socket (for receiving TCP streams) on: 192.168.128.19/192.168.128.19:56558
02-17 10:53:08.072: INFO/MulticastReceiver(5718): Creating wildcard socket (for receiving multicast datagrams) on port: 1900
02-17 10:53:08.082: INFO/MulticastReceiver(5718): Joining multicast group: 239.255.255.250/239.255.255.250:1900 on network interface: eth0
02-17 10:53:08.082: INFO/OSNetworkSystem(5718): mcastAddDropMembership interfaceIndex=25
02-17 10:53:08.082: INFO/DatagramIO(5718): Creating bound socket (for datagram input/output) on: 192.168.128.19/192.168.128.19
02-17 10:53:08.092: DEBUG/****/DirectorActivity.java:128(5718): 10:53:08.099 main ServiceConnection.onServiceConnected
Reply | Threaded
Open this post in threaded view
|

Re: Hanging UI thread on Android

Christian Bauer
Administrator
Gyuri wrote
02-17 10:42:14.866: INFO/NetworkAddressFactory(9096): Discovered WiFi network interface: tiwlan0
...
02-17 10:42:25.085: INFO/StreamServer(9096): Created socket (for receiving TCP streams) on:
All that happens between those two lines is this in RouterImpl:


        streamClient = getConfiguration().createStreamClient();

        for (NetworkInterface networkInterface : networkAddressFactory.getNetworkInterfaces()) {
            MulticastReceiver multicastReceiver = getConfiguration().createMulticastReceiver(networkAddressFactory);
            if (multicastReceiver != null) {
                multicastReceivers.put(networkInterface, multicastReceiver);
            }
        }

        for (InetAddress inetAddress : networkAddressFactory.getBindAddresses()) {

            DatagramIO datagramIO = getConfiguration().createDatagramIO(networkAddressFactory);
            if (datagramIO != null) {
                datagramIOs.put(inetAddress, datagramIO);
            }
            StreamServer streamServer = getConfiguration().createStreamServer(networkAddressFactory);
            if (streamServer != null) {
                streamServers.put(inetAddress, streamServer);
            }
        }

There is no socket binding, no low-level operations, nothing. Just instantiation and a few map iterations. You'll have to do more debugging to find the cause, I'm not seeing this behavior on a Nexus One. Look at the UpnpBrowser main activity example source in the misc downloads for configuration of java.util.logging debug level on Android.

Reply | Threaded
Open this post in threaded view
|

Re: Hanging UI thread on Android

Christian Bauer
Administrator
Actually, there is of course the socket binding the last log line is reporting. I'm not sure why this would block everything else though:

            this.serverSocket =
                    new ServerSocket(
                            configuration.getListenPort(),
                            configuration.getTcpConnectionBacklog(),
                            bindAddress
                    );
Reply | Threaded
Open this post in threaded view
|

Re: Hanging UI thread on Android

alecrim
Hi Gyuri and Christian

I'm facing the same problem. Did you find any solution?

07-20 16:32:57.581: DEBUG/MyActivity(5349): UPnP service bind.
07-20 16:32:57.585: INFO/UpnpServiceImpl(5349): >>> Starting UPnP service...
07-20 16:32:57.585: INFO/UpnpServiceImpl(5349): Using configuration: ***upnp***UPnPService$1
07-20 16:32:57.593: INFO/UpnpServiceImpl(5349): <<< UPnP service started successfully
07-20 16:32:57.597: INFO/Router(5349): WiFi state changed, enabling router
07-20 16:32:57.597: INFO/Router(5349): Creating Router: org.teleal.cling.transport.RouterImpl
07-20 16:32:57.683: DEBUG/dalvikvm(5349): GC_FOR_MALLOC freed 30896 objects / 2042512 bytes in 66ms
07-20 16:32:57.687: INFO/NetworkAddressFactory(5349): Discovered WiFi network interface: eth0
07-20 16:32:59.073: INFO/AudioHardwareALSA(2407): Output standby called!!. Turn off PCM device.
07-20 16:33:00.019: VERBOSE/AlarmManager(2522): set: Alarm{482145e0 type 1 android}
07-20 16:33:02.535: WARN/PowerManagerService(2522): Timer 0x7->0x3|0x3
07-20 16:33:02.535: INFO/PowerManagerService(2522): Ulight 7->3|0
07-20 16:33:07.706: INFO/StreamServer(5349): Created socket (for receiving TCP streams) on: 192.168.1.167/192.168.1.167:38650
07-20 16:33:07.710: INFO/MulticastReceiver(5349): Creating wildcard socket (for receiving multicast datagrams) on port: 1900
07-20 16:33:07.714: INFO/MulticastReceiver(5349): Joining multicast group: 239.255.255.250/239.255.255.250:1900 on network interface: eth0
07-20 16:33:07.714: INFO/OSNetworkSystem(5349): mcastAddDropMembership interfaceIndex=7
07-20 16:33:07.738: INFO/DatagramIO(5349): Creating bound socket (for datagram input/output) on: 192.168.1.167/192.168.1.167
07-20 16:33:07.765: DEBUG/MyActivity(5349): UPnP service connected.

Thanks,
Alecrim.
Reply | Threaded
Open this post in threaded view
|

Re: Hanging UI thread on Android

Christian Bauer
Administrator
This might be related to a reverse DNS lookup issue that is currently being discussed. There is a pinned thread here on the forum.
Reply | Threaded
Open this post in threaded view
|

Re: Hanging UI thread on Android

Vadim Eisenberg
In reply to this post by Christian Bauer
Christian Bauer wrote
You "bind" and then asynchronously some thread will create the service instance and call its onCreate() method. I'm not sure if there is even controls for this behavior, you should look into what/how threads are created for service binding. If indeed the UI thread is used then that would block and I'd call that a bug in Android.
Cristian - please note that it is the documented thread behavior of Android http://developer.android.com/guide/topics/fundamentals/processes-and-threads.html#Threads : The system does not create a separate thread for each instance of a component. All components that run in the same process are instantiated in the UI thread, and system calls to each component are dispatched from that thread.

I experience more than 20 seconds time of UPnP service initialization on Nexus S. I guess it is related to the reverse DNS lookup and maybe other network issues. The problem for me is not with the initialization time, but with hanging the UI thread. Binding to the AndroidUpnpServiceImpl in a separate thread does not help, since the bound service is instantiated in the UI thread in any case.

A simple solution to all the long initialization issues (the current and possible future ones) could be to run the creation of UpnpServiceImpl in a separate thread in AndroidUpnpServiceImpl , and using some flag for the separate thread to indicate that it finished the initialization. The returned binder could wait until the upnpService is initialized before accessing it in the getter methods.
Vadim Eisenberg
IT for Healthcare & Life Sciences
IBM Research - Haifa
Reply | Threaded
Open this post in threaded view
|

Re: Hanging UI thread on Android

Christian Bauer
Administrator
I'm quite certain that the reason for a 20 second delay is the reverse DNS bug in Android. As discussed earlier here, nothing much happens on startup except socket binding - with potentially the reverse lookup. This is on the issue list already but if you can find another reason for the delay you are seeing, we can discuss it.
Reply | Threaded
Open this post in threaded view
|

Re: Hanging UI thread on Android

Michael Pujos
Christian Bauer wrote
I'm quite certain that the reason for a 20 second delay is the reverse DNS bug in Android. As discussed earlier here, nothing much happens on startup except socket binding - with potentially the reverse lookup. This is on the issue list already but if you can find another reason for the delay you are seeing, we can discuss it.
That's it for sure. Nothing else is potentially blocking.
The fix is to modify the code as I explain in the first post of the dedicated topic to this issue.
But even if that fix initialization, it won't help with later HttpClient requests whose DNS lookup mail fail for some devices, and there is no workaround possible.
Reply | Threaded
Open this post in threaded view
|

Re: Hanging UI thread on Android

Christian Bauer
Administrator
Michael, have you seen the last post here: http://mailinglists.945824.n3.nabble.com/Android-and-reverse-DNS-lookup-issues-td3011461.html#a3148633

There is a workaround on the issue tracker: http://code.google.com/p/android/issues/detail?id=13117#c14

Maybe you can try this and we can include it later.
Reply | Threaded
Open this post in threaded view
|

Re: Hanging UI thread on Android

Michael Pujos
Christian Bauer wrote
Michael, have you seen the last post here: http://mailinglists.945824.n3.nabble.com/Android-and-reverse-DNS-lookup-issues-td3011461.html#a3148633

There is a workaround on the issue tracker: http://code.google.com/p/android/issues/detail?id=13117#c14

Maybe you can try this and we can include it later.
This should work with some modifications, the workaround being for https.
I've modified cling to use HttpClient 4.1.1 (repackaged so it doesn't conflict with the platform's). The factory is a bit different but it still should still be doable:

http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/conn/scheme/SchemeSocketFactory.html

I'll try it and let you know.
Reply | Threaded
Open this post in threaded view
|

Re: Hanging UI thread on Android

Vadim Eisenberg
Christian, Michael,

I probably was not clear in my post. My intention was that even if you solve the current long initialization problem now, you never know which problems could appear in the future and which bugs could happen in the future Android versions. So in order to be on the safe side, I think it would be better to run the creation of UpnpServiceImpl in a separate thread anyway.

If the current bug will be resolved and UpnpServiceImpl creation will be fast - I guess no harm will be caused by running the separate thread - you just get a protection against possible future Android bugs, just as a precaution measure.
Vadim Eisenberg
IT for Healthcare & Life Sciences
IBM Research - Haifa
Reply | Threaded
Open this post in threaded view
|

Re: Hanging UI thread on Android

Michael Pujos
In reply to this post by Michael Pujos
Michael Pujos wrote
Christian Bauer wrote
Michael, have you seen the last post here: http://mailinglists.945824.n3.nabble.com/Android-and-reverse-DNS-lookup-issues-td3011461.html#a3148633

There is a workaround on the issue tracker: http://code.google.com/p/android/issues/detail?id=13117#c14

Maybe you can try this and we can include it later.
This should work with some modifications, the workaround being for https.
I've modified cling to use HttpClient 4.1.1 (repackaged so it doesn't conflict with the platform's). The factory is a bit different but it still should still be doable:

http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/conn/scheme/SchemeSocketFactory.html

I'll try it and let you know.
OK. This hack for https cannot work with http as is. a LayeredSocketFactory is needed and HttpClient will call  LayeredSocketFactory.createSocket() only for tunnelled routes. *Maybe* this could be made working, emulating how the SSL layering is implemented but it requires level 100+ in httpclient internals knowledge :).
Reply | Threaded
Open this post in threaded view
|

Re: Hanging UI thread on Android

Robert
Hi everyone!

In the end, was there some solution to this problem?

I'm using cling core 1.0.5. in Android version gingerbread. So I have tried to fix with http://code.google.com/p/android/issues/detail?id=13117#c14.
But i don't work anything.

Log
02-18 10:10:05.628: I/Router(1447): Creating Router: org.teleal.cling.transport.RouterImpl
02-18 10:10:05.648: I/NetworkAddressFactory(1447): Discovered WiFi network interface: wlan0
02-18 10:10:25.678: I/StreamServer(1447): Created socket (for receiving TCP streams) on: 192.168.1.101/192.168.1.101:53701
02-18 10:10:25.678: I/MulticastReceiver(1447): Creating wildcard socket (for receiving multicast datagrams) on port: 1900

Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: Hanging UI thread on Android

Christian Bauer
Administrator
Cling 2 avoids reverse DNS lookups on Android.

Reply | Threaded
Open this post in threaded view
|

Re: Hanging UI thread on Android

Robert
thanks for your reply!!!



I've changed to cling 2 but now i have the following problem.

I have loaded "cling-core-2.0-alpha2.jar", "cling-core-2.0-alpha2-sources.jar" , "seamless-http-1.0-alpha2.jar" ,
"seamless-util-1.0-alpha2.jar" , "seamless-xml-1.0-alpha2.jar" into the libs folder of Android project version 2.3.3

I hadn't had any problem with cling 1 with the same way.


Log
02-26 22:53:36.591: I/Inicio(3171): Start activity
02-26 22:53:36.611: I/Inicio(3171): Invoca al Service Connection
02-26 22:53:36.761: I/ActivityThread(3171): exit process activity msg = 100
02-26 22:53:36.761: I/ActivityThread(3171): enter process activity msg = 114
02-26 22:53:36.851: I/UpnpServiceImpl(3171): >>> Starting UPnP service...
02-26 22:53:36.861: I/UpnpServiceImpl(3171): Using configuration: org.fourthline.cling.android.AndroidUpnpServiceConfiguration
02-26 22:53:36.881: I/Router(3171): Creating Router: org.fourthline.cling.android.AndroidRouter
02-26 22:53:36.891: W/dalvikvm(3171): VFY: unable to resolve virtual method 3632: Ljava/net/NetworkInterface;.isLoopback ()Z
02-26 22:53:36.901: I/ActivityThread(3171): Receiving broadcast android.net.conn.CONNECTIVITY_CHANGE to org.fourthline.cling.android.AndroidRouter$ConnectivityBroadcastReceiver@2ff21a70
02-26 22:53:36.901: W/dalvikvm(3171): DexOpt: resolve class illegal access: Lorg/fourthline/cling/transport/impl/NetworkAddressFactoryImpl; -> Ljava/net/InterfaceAddress;
02-26 22:53:36.901: E/dalvikvm(3171): Could not find class 'java.net.InterfaceAddress', referenced from method org.fourthline.cling.transport.impl.NetworkAddressFactoryImpl.getAddressNetworkPrefixLength
02-26 22:53:36.901: W/dalvikvm(3171): VFY: unable to resolve check-cast 589 (Ljava/net/InterfaceAddress;) in Lorg/fourthline/cling/transport/impl/NetworkAddressFactoryImpl;
02-26 22:53:36.911: W/dalvikvm(3171): DexOpt: resolve class illegal access: Lorg/fourthline/cling/transport/impl/NetworkAddressFactoryImpl; -> Ljava/net/InterfaceAddress;
02-26 22:53:36.911: E/dalvikvm(3171): Could not find class 'java.net.InterfaceAddress', referenced from method org.fourthline.cling.transport.impl.NetworkAddressFactoryImpl.getBindAddressInSubnetOf
02-26 22:53:36.911: W/dalvikvm(3171): VFY: unable to resolve check-cast 589 (Ljava/net/InterfaceAddress;) in Lorg/fourthline/cling/transport/impl/NetworkAddressFactoryImpl;
02-26 22:53:36.911: W/dalvikvm(3171): DexOpt: resolve class illegal access: Lorg/fourthline/cling/transport/impl/NetworkAddressFactoryImpl; -> Ljava/net/InterfaceAddress;
02-26 22:53:36.911: E/dalvikvm(3171): Could not find class 'java.net.InterfaceAddress', referenced from method org.fourthline.cling.transport.impl.NetworkAddressFactoryImpl.getBroadcastAddress
02-26 22:53:36.911: W/dalvikvm(3171): VFY: unable to resolve check-cast 589 (Ljava/net/InterfaceAddress;) in Lorg/fourthline/cling/transport/impl/NetworkAddressFactoryImpl;
02-26 22:53:36.911: W/dalvikvm(3171): VFY: unable to resolve virtual method 3624: Ljava/net/NetworkInterface;.getHardwareAddress ()[B
02-26 22:53:36.911: W/dalvikvm(3171): VFY: unable to resolve virtual method 3626: Ljava/net/NetworkInterface;.getInterfaceAddresses ()Ljava/util/List;
02-26 22:53:36.911: W/dalvikvm(3171): VFY: unable to resolve virtual method 3634: Ljava/net/NetworkInterface;.isUp ()Z
02-26 22:53:36.911: W/dalvikvm(3171): VFY: unable to resolve virtual method 3630: Ljava/net/NetworkInterface;.getParent ()Ljava/net/NetworkInterface;
02-26 22:53:36.921: W/dalvikvm(3171): threadid=1: thread exiting with uncaught exception (group=0x2aacc8a0)
02-26 22:53:36.931: E/AndroidRuntime(3171): FATAL EXCEPTION: main
02-26 22:53:36.931: E/AndroidRuntime(3171): java.lang.NoSuchMethodError: java.net.NetworkInterface.isUp
02-26 22:53:36.931: E/AndroidRuntime(3171): at org.fourthline.cling.transport.impl.NetworkAddressFactoryImpl.isUsableNetworkInterface(NetworkAddressFactoryImpl.java:341)
02-26 22:53:36.931: E/AndroidRuntime(3171): at org.fourthline.cling.transport.impl.NetworkAddressFactoryImpl.discoverNetworkInterfaces(NetworkAddressFactoryImpl.java:303)
02-26 22:53:36.931: E/AndroidRuntime(3171): at org.fourthline.cling.android.AndroidNetworkAddressFactory.discoverNetworkInterfaces(AndroidNetworkAddressFactory.java:85)
02-26 22:53:36.931: E/AndroidRuntime(3171): at org.fourthline.cling.transport.impl.NetworkAddressFactoryImpl.<init>(NetworkAddressFactoryImpl.java:90)
02-26 22:53:36.931: E/AndroidRuntime(3171): at org.fourthline.cling.android.AndroidNetworkAddressFactory.<init>(AndroidNetworkAddressFactory.java:40)
02-26 22:53:36.931: E/AndroidRuntime(3171): at org.fourthline.cling.android.AndroidUpnpServiceConfiguration.createNetworkAddressFactory(AndroidUpnpServiceConfiguration.java:77)
02-26 22:53:36.931: E/AndroidRuntime(3171): at org.fourthline.cling.DefaultUpnpServiceConfiguration.createNetworkAddressFactory(DefaultUpnpServiceConfiguration.java:257)
02-26 22:53:36.931: E/AndroidRuntime(3171): at org.fourthline.cling.transport.RouterImpl.enable(RouterImpl.java:129)
02-26 22:53:36.931: E/AndroidRuntime(3171): at org.fourthline.cling.android.AndroidRouter.enable(AndroidRouter.java:88)
02-26 22:53:36.931: E/AndroidRuntime(3171): at org.fourthline.cling.UpnpServiceImpl.<init>(UpnpServiceImpl.java:87)
02-26 22:53:36.931: E/AndroidRuntime(3171): at org.fourthline.cling.android.AndroidUpnpServiceImpl$1.<init>(AndroidUpnpServiceImpl.java:54)
02-26 22:53:36.931: E/AndroidRuntime(3171): at org.fourthline.cling.android.AndroidUpnpServiceImpl.onCreate(AndroidUpnpServiceImpl.java:54)
02-26 22:53:36.931: E/AndroidRuntime(3171): at android.app.ActivityThread.handleCreateService(ActivityThread.java:3001)
02-26 22:53:36.931: E/AndroidRuntime(3171): at android.app.ActivityThread.access$3300(ActivityThread.java:132)
02-26 22:53:36.931: E/AndroidRuntime(3171): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2125)
02-26 22:53:36.931: E/AndroidRuntime(3171): at android.os.Handler.dispatchMessage(Handler.java:99)
02-26 22:53:36.931: E/AndroidRuntime(3171): at android.os.Looper.loop(Looper.java:123)
02-26 22:53:36.931: E/AndroidRuntime(3171): at android.app.ActivityThread.main(ActivityThread.java:4669)
02-26 22:53:36.931: E/AndroidRuntime(3171): at java.lang.reflect.Method.invokeNative(Native Method)
02-26 22:53:36.931: E/AndroidRuntime(3171): at java.lang.reflect.Method.invoke(Method.java:521)
02-26 22:53:36.931: E/AndroidRuntime(3171): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:876)
02-26 22:53:36.931: E/AndroidRuntime(3171): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:634)
02-26 22:53:36.931: E/AndroidRuntime(3171): at dalvik.system.NativeStart.main(Native Method)






Like this, I invoke to bindService

getApplicationContext().bindService(
                                new Intent(MainActivity.this, org.fourthline.cling.android.AndroidUpnpServiceImpl.class),
                                serviceConnection, Context.BIND_AUTO_CREATE);