@ Override protected void onStart ( ) { m_mappings = new HashMap < Bundle , List < T > > ( ) ; // listen to bundles events m_context . addBundleListener ( m_bundleListener = new SynchronousBundleListener ( ) { public void bundleChanged ( final BundleEvent bundleEvent ) { switch ( bundleEvent . getType ( ) ) { case BundleEvent . STARTED : register ( bundleEvent . getBundle ( ) ) ; break ; case BundleEvent . STOPPED : unregister ( bundleEvent . getBundle ( ) ) ; break ; } } } ) ; // scan already started bundles Bundle [ ] bundles = m_context . getBundles ( ) ; if ( bundles != null ) { for ( Bundle bundle : bundles ) { if ( bundle . getState ( ) == Bundle . ACTIVE ) { register ( bundle ) ; } } } }
Registers a listener for bundle events and scans already active bundles .