1

사용자가 설정 응용 프로그램 내에서 자신의 계정을 만들고 관리 할 수 ​​있도록 내 응용 프로그램에 AccountManager 코드를 포함 시켰습니다.account-authenticator accountPreferences 화면에서 Intent를 실행 하시겠습니까?

내 계정 인증 자 정의 내의 "accountPreferences"환경 설정 파일에 링크되어 있으며 설정> 계정> 내 앱 화면에서 옵션이 올바르게 표시됩니다. 내가 대신 내가 링크 된 활동을 얻는, 그 중 하나를 탭하면, 내가 얻을 :

<intent 
    android:action="android.intent.action.VIEW" 
    android:targetPackage="com.myapp.android" 
    android:targetClass="com.myapp.android.activities.AccountForwardingActivity"/> 

그리고 대상 활동도 :

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) 

나는 정의 내 PreferenceScreen 내 의도를 가지고 (다른 사용자 지정 작업도 나열되어 있습니다) 해당 동작과 일치하는 인 텐트 필터 이외의 특별한 플래그가없는 상태로 정의됩니다.

<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> 

내가 뭘 잘못하고 있니? Settings.apk에서 시작된이 의도를 새로운 작업으로 표시하려면 어떻게해야합니까?

답변

6

내 문제는 내 PreferenceCategory 내에 환경 설정 화면을 넣는 것이 었습니다.

이 잘 작동 :

<PreferenceCategory android:title="General Settings" /> 
<PreferenceScreen 
    android:title="Account Settings" 
    android:summary="Favorites, Orders, and more."> 
    <intent 
     android:action="android.intent.action.VIEW" 
     android:targetPackage="com.myapp.android" 
     android:targetClass="com.myapp.android.activities.AccountForwardingActivity"/> 
</PreferenceScreen> 

중첩는 PreferenceCategory 내부 PreferenceScreen이 작동하지 않는, 위의 오류가 발생합니다.

+0

답변을 수락 한 것으로 표시 할 수 있습니다. 유효한 수정 사항입니다. –