title: When to use which constructor for ComponentName in Android?
body: <p>I am a little bit confused about the ComponentName class in Android.</p>
  
  <p>There are different ways to get to a component name object, but I don't know when to use which... and why!</p>
  
  <p>Example:</p>
  
  <ul>
  <li>Application package is <code>de.zordid.sampleapp</code></li>
  <li>but widget provider class is <code>de.zordid.sampleapp.widget.WidgetProvider</code></li>
  </ul>
  
  <p>Using </p>
  
  <pre><code>ComponentName cn = new ComponentName("de.zordid.sampleapp.widget",
      "WidgetProvider");
  </code></pre>
  
  <p>I got this component info: <code>ComponentInfo{de.zordid.sampleapp.widget/WidgetProvider}</code>, but I could not use this - the component is unknown!
  But the JavaDoc says I should give the package and the class within that package - and that is what I did, didn't I??</p>
  
  <p>Using</p>
  
  <pre><code>ComponentName cn = new ComponentName(context, WidgetProvider.class);
  </code></pre>
  
  <p>yields <code>ComponentInfo{de.zordid.sampleapp/de.zordid.sampleapp.widget.WidgetProvider}</code> - and that works fine!!</p>
  
  <p>There is even another way to get a ComponentName - by context and a string.
  Which one should be used where and when??</p>
  
  <p>Thanks!</p>