title: PreferenceScreen - <intent .../> - Exception - FLAG_ACTIVITY_NEW_TASK
body: <p>I am new at android developing.</p>
  
  <p>The project is about implementing an AbstractAccountAuthenticator with an AbstractThreadedSyncAdapter to sync certain data on a server with a content provider.</p>
  
  <p>I made everything and both adding accounts and syncing is running without any problems.</p>
  
  <p>Now I've tried to add a Preference-Screen just like suggested in the android reference (search for AbstractAccountAuthenticator, it is explained there) via xml like this:</p>
  
  <p><strong>autenticator.xml:</strong></p>
  
  <pre><code>&lt;account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
      android:accountType="typeOfAuthenticator"
      android:icon="@drawable/icon"
      android:smallIcon="@drawable/miniIcon"
      android:label="@string/label"
      android:accountPreferences="@xml/account_preferences"
   /&gt;
  </code></pre>
  
  <p>The Preference-Screen-xml looks like this:</p>
  
  <p><strong>account_preferences.xml:</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"&gt;
   &lt;PreferenceCategory android:title="@string/pref_cat_general"&gt;
    &lt;PreferenceScreen android:key="@string/pref_cat_scr_keygen" android:title="@string/pref_cat_scr_keygen_title" android:summary="@string/pref_cat_scr_keygen_summary"&gt;
     &lt;intent android:action="android.intent.action.VIEW" android:targetPackage="com.android.clean" android:targetClass="com.android.clean.KeygenAct" /&gt;
    &lt;/PreferenceScreen&gt;
   &lt;/PreferenceCategory&gt;
  &lt;/PreferenceScreen&gt;
  </code></pre>
  
  <p>The screen is promted how it should be, but and that is the problem: When I click on the PreferenceScreen with the intent it leads to a crash of the system (both in the emulator and my HTC-Desire). </p>
  
  <p>Logcat says: </p>
  
  <blockquote>
    <p>ERROR/AndroidRuntime(18754):
    android.util.AndroidRuntimeException:
    Calling startActivity() from outside
    of an Activity  context requires the
    FLAG_ACTIVITY_NEW_TASK flag. Is this
    really what you want?</p>
  </blockquote>
  
  <p>(whole <a href="http://pastebin.com/cyzkwmYw" rel="noreferrer">Logcat on pastebin</a>)</p>
  
  <p>Here the part of the manifest, where the activity is defined:</p>
  
  <pre><code>&lt;activity android:name=".KeygenAct"&gt;
      &lt;intent-filter&gt;
       &lt;action android:name="android.intent.action.VIEW" /&gt;
       &lt;category android:name="android.intent.category.DEFAULT" /&gt;
      &lt;/intent-filter&gt;
  &lt;/activity&gt;
  </code></pre>
  
  <p>The whole test-code (it is my project on the essentials to find the problem) is to find at googlecode (<a href="http://code.google.com/p/cleanproject/source/browse/" rel="noreferrer">http://code.google.com/p/cleanproject/source/browse/</a>) (Eclipse-Project)</p>
  
  <p>Thank you already for your help, 
  Esentian</p>
  
  <p>p.s.: keygen is not a key generator, it means more key_general. A bit inartfully expressed ;)</p>