title: How to construct an intent object with a subclass of the defined class?
body: <p>I want to have a function to build and start an activity of certain class and its subclass, let say I have two activity <code>A</code> and <code>B</code></p>
  
  <pre><code>public class A extends AppCompatActivity {...}
  
  public class B extends A {...}
  </code></pre>
  
  <p>I have a function in MainActivity called <code>startAActivity()</code></p>
  
  <pre><code>private void startAActivity(Object someExtra, Class&lt;A&gt; activityClass) {
    Intent i = new Intent(MainActivity.class, activityClass);
    i.putExtra(SOME_EXTRA, someExtra);
    startActivity(i);
  }
  </code></pre>
  
  <p>if I call <code>startAActivity(extra, B.class)</code> I will get an error because it is expecting the Class object of class A, I know I can just put a <code>?</code> in the function signature to make it work, but since B is a subclass of A, is there a way that I can keep the parameter as <code>Class&lt;A&gt; activityClass</code> so that <code>Class&lt;B&gt;</code> will be treated as <code>Class&lt;A&gt;</code>? Just for more Polymorphism?</p>