If you think the Android project DroidUPnP listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/**
* Copyright (C) 2013 Aurlien Chabot <aurelien@chabot.fr>
* //www.java2s.com
* This file is part of DroidUPNP.
*
* DroidUPNP is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* DroidUPNP is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with DroidUPNP. If not, see <http://www.gnu.org/licenses/>.
*/package org.droidupnp.model.cling;
import org.droidupnp.model.upnp.IRegistryListener;
import org.fourthline.cling.model.meta.LocalDevice;
import org.fourthline.cling.model.meta.RemoteDevice;
import org.fourthline.cling.registry.DefaultRegistryListener;
import org.fourthline.cling.registry.Registry;
publicclass CRegistryListener extends DefaultRegistryListener {
privatefinal IRegistryListener registryListener;
public CRegistryListener(IRegistryListener registryListener)
{
this.registryListener = registryListener;
}
/* Discovery performance optimization for very slow Android devices! */
@Override
publicvoid remoteDeviceDiscoveryStarted(Registry registry, RemoteDevice device)
{
registryListener.deviceAdded(new CDevice(device));
}
@Override
publicvoid remoteDeviceDiscoveryFailed(Registry registry, final RemoteDevice device, final Exception ex)
{
registryListener.deviceRemoved(new CDevice(device));
}
/* End of optimization, you can remove the whole block if your Android handset is fast (>= 600 Mhz) */
@Override
publicvoid remoteDeviceAdded(Registry registry, RemoteDevice device)
{
registryListener.deviceAdded(new CDevice(device));
}
@Override
publicvoid remoteDeviceRemoved(Registry registry, RemoteDevice device)
{
registryListener.deviceRemoved(new CDevice(device));
}
@Override
publicvoid localDeviceAdded(Registry registry, LocalDevice device)
{
registryListener.deviceAdded(new CDevice(device));
}
@Override
publicvoid localDeviceRemoved(Registry registry, LocalDevice device)
{
registryListener.deviceRemoved(new CDevice(device));
}
}