title: Start an Intent where the Class Name is a Variable?
body: <p>I'm trying to access an intent from a string variable that represents the intent's name, <code>nIntent</code>.</p>
  
  <p><strong>Question:</strong> If I replace the variable <code>nIntent</code> with the <code>QueryDisplay.class</code> name, it fires correctly, but if I use a variable, why do I get the typical <code>No Activity found to handle Intent { act=QueryDisplay.class (has extras) }</code>?</p>
  
  <p>I don't get it because it works fine hard-coded (it's in the manifest).  Any ideas?</p>
  
  <p>Thanks for your help.</p>
  
  <pre><code>lv.setOnItemClickListener(new OnItemClickListener() {
  
              @Override
              public void onItemClick(AdapterView&lt;?&gt; arg0, View v, int arg2,
                      long arg3) {
  
                  String url = "";
                  url = (String) v.getTag();
  
                  int nI = c.getColumnIndexOrThrow("intent");
                  String nIntent = c.getString(nI);
  
                  int tvTitle = c.getColumnIndexOrThrow("title");
                  String title = c.getString(tvTitle);
  
                  int tvLabel = c.getColumnIndexOrThrow("label");
                  String label = c.getString(tvLabel);
  
                  String queryKey = "SELECT * FROM " + label + " ORDER BY `_id` ASC";
  
                  //Intent i = new Intent(nIntent);&lt;- This doesn't?? work
                  Intent i = new Intent(this, QueryDisplay.class);&lt;- This works
                  i.putExtra("QUERY_KEY", queryKey);
                  i.putExtra("url", url);
                  i.putExtra("TITLE", title);
                  i.putExtra("LABEL", label);
                  QueryDisplay.this.startActivity(i);
              }
          });
  </code></pre>
  
  <p>UPDATE:  Here is the correct code:</p>
  
  <pre><code>lv.setOnItemClickListener(new OnItemClickListener() {
  
              @Override
              public void onItemClick(AdapterView&lt;?&gt; arg0, View v, int arg2,
                      long arg3) {
  
                  String url = "";
                  url = (String) v.getTag();
  
                  int nI = c.getColumnIndexOrThrow("intent");
                  String intent = c.getString(nI);
                  Class&lt;?&gt; nIntent = null;
                  try {
                      nIntent = Class.forName(intent);
                  } catch (ClassNotFoundException e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                  }
  
                  int tvTitle = c.getColumnIndexOrThrow("title");
                  String title = c.getString(tvTitle);
  
                  int tvLabel = c.getColumnIndexOrThrow("label");
                  String label = c.getString(tvLabel);
  
                  String queryKey = "SELECT * FROM " + label + " ORDER BY `_id` ASC";
  
                  Intent i = new Intent(QueryDisplay.this, nIntent);
                  i.putExtra("QUERY_KEY", queryKey);
                  i.putExtra("url", url);
                  i.putExtra("TITLE", title);
                  i.putExtra("LABEL", label);
                  QueryDisplay.this.startActivity(i);
              }
          });
  </code></pre>