title: Programmatically starting the 'Add Google Account' activity in Android
body: <p>I am developing an application which needs a Google account for certain options.
  Options are disabled when no account is detected, but I am presenting the user to add one by asking via a popup, if user clicks yes, the activity should start.
  It's working fine to display the global "Add account" page, but I want to skip that uncalled for extra step. After all, why present someone with the option to add a Exchange account if a Google account is needed, that's just confusing. So I want to default to the new Google account setup page.</p>
  
  <p><strong>Java</strong></p>
  
  <pre><code>try {
      Intent intent = new Intent();
      intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
      intent.setClassName( "com.google.android.gsf", "com.google.android.gsf.login.AccountIntroActivity");
  
      //if(getApplicationContext().getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY) != null) {
          getApplicationContext().startActivity(intent);
      //} else {
          //getApplicationContext().startActivity(new Intent(Settings.ACTION_ADD_ACCOUNT).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
      //}
  } catch ( ActivityNotFoundException e) {
      e.printStackTrace();
  }
  </code></pre>
  
  <p>When I run this, the following exeception is thrown:</p>
  
  <p>05-29 18:24:50.741: W/System.err(10875): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.google.android.gsf/com.google.android.gsf.login.AccountIntroActivity}; have you declared this activity in your AndroidManifest.xml?</p>
  
  <p><strong>Androidmanifest.xml</strong></p>
  
  <pre><code>    &lt;activity 
          android:name="com.google.android.gsf.login.AccountIntroActivity"/&gt;   
  </code></pre>
  
  <p><strong>QUESTION:</strong> what am I missing here?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I tried a different way using addAccount, this doesn't work, nothing happens, no errors are thrown, no new activity starts to add the Google account. By the way, the entire try catch block in the original version is in a AlertDialog/ listener.</p>
  
  <pre><code>AccountManager acm = AccountManager.get();
  acm.addAccount("com.google", null, null, null, null, null, null);           
  </code></pre>