公共无效onServiceConnected未执行,没有错误

时间:2019-02-14 19:34:24

标签: cling android-cling

我使用Cling但绑定了服务连接:

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

    public void onServiceConnected(ComponentName className, IBinder service) {
           upnpService = (AndroidUpnpService) service;
           on = 1;
           // Clear the list
           listAdapter.clear();

           // Get ready for future device advertisements
           upnpService.getRegistry().addListener(registryListener);


           // Now add all devices to the list we already know about
           for (Device device : upnpService.getRegistry().getDevices()) {
               registryListener.deviceAdded(device);
           }

           Log.i("MainActivity", "Started");

           // Search asynchronously for all devices, they will respond soon
           upnpService.getControlPoint().search();


       }

       public void onServiceDisconnected(ComponentName className) {
           upnpService = null;
       }
   };

onServiceConnected无法执行,我不知道为什么。

我不知道绑定服务是否有效 我已使用此代码开始使用cling:https://github.com/4thline/cling/tree/master/demo/android/browser/src/main/java/org/fourthline/cling/demo/android/browser

0 个答案:

没有答案