title: Correct use of Classloader (especially in Android)
body: <p>I read some documentations about classloaders, but im still not sure where and why they are needed. The Android API says:</p>
  
  <blockquote>
    <p>Loads classes and resources from a
    repository. One or more class loaders
    are installed at runtime. These are
    consulted whenever the runtime system
    needs a specific class that is not yet
    available in-memory.</p>
  </blockquote>
  
  <p>So if i understand this correct, there can be many classlaoders which are responsible for loading new classes. But how the system decides which to use? And in which situation should a developer instantiate a new classloader?</p>
  
  <p>In the Android API for Intent there is a method</p>
  
  <pre><code>public void  setExtrasClassLoader  (ClassLoader  loader)
  </code></pre>
  
  <p>The description says:</p>
  
  <blockquote>
    <p>Sets the ClassLoader that will be used
    when unmarshalling any Parcelable
    values from the extras of this Intent.</p>
  </blockquote>
  
  <p>So can i define there a special classloader so that i can pass object with an Intent which are not defined in the receiving activity? An example:</p>
  
  <p>If activity A which is located in Project A (in Eclipse) defines an object which i want to send to Activity B in Project B using putExtra of the Intent object. If this object which is send over the Intent is not defined (source code in project B), then there is a NoClassDefFoundException. So can i use the method setExtraClassloader to avoid this exception? If yes, how can i decide which classloader object i have to pass? And how do I instantiate it correctly?</p>