I have included the AccountManager code in my application to allow the user to create and manage their account from the Settings application.
I contacted the "accountPreferences" settings file inside the definition of my account authenticator, and the settings are displayed correctly on the "Settings"> "Accounts"> "My Applications" screen. When I click on one of them, instead of getting the activity that I'm associated with, I get:
01-14 14:47:27.304: ERROR/AndroidRuntime(27708): FATAL EXCEPTION: main android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want? at android.app.ContextImpl.startActivity(ContextImpl.java:944) at android.app.ContextImpl.startActivity(ContextImpl.java:931) at android.preference.Preference.performClick(Preference.java:967) at android.preference.PreferenceScreen.onItemClick(PreferenceScreen.java:215)
I have intentions inside my PreferenceScreen, defined as:
<intent android:action="android.intent.action.VIEW" android:targetPackage="com.myapp.android" android:targetClass="com.myapp.android.activities.AccountForwardingActivity"/>
And the target activity is also determined as you expected, without special flags other than the filter intent to match this action (I have other user actions listed as well).
<activity android:name=".activities.AccountForwardingActivity" android:theme="@style/Theme.MyApp" android:launchMode="singleTask"> <intent-filter> <action android:name="com.myapp.android.PAYMENT_TYPES"/> <action android:name="com.myapp.android.ADDRESS_LIST"/> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity>
What am I doing wrong? How can I mark this intention, launched from Settings.apk, for a new task?
source share