Android - RegistryListener error

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

Android - RegistryListener error

xlehoc01
This post was updated on .
Hi,

I am new in Cling and Android, and I am having trouble with it.
My application is similar to Browser Demo application but it doesn't work.

It looks like this:

public class MainActivity extends Activity {
	
    private class BrowseRegistryListener extends DefaultRegistryListener { ... } //same as Browser Demo App
    
    private class DeviceDisplay { ... } // same as Browser Demo App
    
    private ListView upnpList; 
    private Button rescan;
    private TextView scanStatus;
    private ArrayAdapter<DeviceDisplay> listAdapter;
    private BrowseRegistryListener registryListener;
    private AndroidUpnpService upnpService;   
    private ServiceConnection serviceConnection;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
                
        serviceConnection = new ServiceConnection() {

            public void onServiceConnected(ComponentName className, IBinder service) {          	            	
                upnpService = (AndroidUpnpService) service;
                listAdapter.clear();
                upnpService.getRegistry().addListener(registryListener);
                for (Device device : upnpService.getRegistry().getDevices()) {
                    registryListener.deviceAdded(device);
                }
                upnpService.getControlPoint().search();
            }

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

        registryListener = new BrowseRegistryListener();            
        scanStatus = (TextView)findViewById(R.id.status);
        upnpList = (ListView)this.findViewById(R.id.foundList);           
        listAdapter = new ArrayAdapter<DeviceDisplay>(this, android.R.layout.simple_list_item_1);
        upnpList.setAdapter(listAdapter);
        
        getApplicationContext().bindService(new Intent(this, BrowserUpnpService.class), serviceConnection, Context.BIND_AUTO_CREATE); 
        
        scanStatus.setText("started");
        
        rescan = (Button)findViewById(R.id.rescanBtn);
        rescan.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				refreshList();	
			}
		});
        
        refreshList();	       
        upnpList.invalidate();
        scanStatus.setText("finished");       
    }

    private void refreshList(){   	
    	scanStatus.setText("scanning ...");   	                
        if (upnpService == null){
        	scanStatus.setText("FAILED");
        	return;
        }      
        upnpService.getRegistry().removeAllRemoteDevices();
        upnpService.getControlPoint().search();
        scanStatus.setText("---->scaned");        
    }
       
    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (upnpService != null) {
            upnpService.getRegistry().removeListener(registryListener);
        }
        getApplicationContext().unbindService(serviceConnection);
    }
    
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
}

and also i have the:

public class BrowserUpnpService extends AndroidUpnpServiceImpl {.....}

When I start this application, I get error like:

Could not find class '...MainActivity$BrowseRegisrtyListener', referenced from method ....MainActivity.onCreate


What can be the problem that it does not find this class? 

I have the Cling added to build path as a different Java Project with all the includes resolved.
Reply | Threaded
Open this post in threaded view
|

Re: Android - RegistryListener error

DREDD112
Not the same. Look more attentively.
Reply | Threaded
Open this post in threaded view
|

Re: Android - RegistryListener error

xlehoc01
If I copy there the original code of the BrowseActivity.java source to my, i get the same error ...