私はAndroid開発の初心者です。
このプロジェクトは、AbstractThreadedSyncAdapterを使用してAbstractAccountAuthenticatorを実装し、サーバー上の特定のデータをコンテンツプロバイダーと同期することを目的としています。
私はすべてを作成し、アカウントの追加と同期の両方が問題なく実行されています。
今、私は次のようなxmlを介してAndroidリファレンス(AbstractAccountAuthenticatorを検索し、そこで説明されています)で提案されているようにPreference-Screenを追加しようとしました:
autenticator.xml:
<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"
/>
Preference-Screen-xmlは次のようになります。
account_preferences.xml:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="@string/pref_cat_general">
<PreferenceScreen android:key="@string/pref_cat_scr_keygen" android:title="@string/pref_cat_scr_keygen_title" android:summary="@string/pref_cat_scr_keygen_summary">
<intent android:action="android.intent.action.VIEW" android:targetPackage="com.android.clean" android:targetClass="com.android.clean.KeygenAct" />
</PreferenceScreen>
</PreferenceCategory>
</PreferenceScreen>
画面は本来あるべき姿で表示されますが、それが問題です。意図的にPreferenceScreenをクリックすると、システムがクラッシュします(エミュレーターとHTC-Desireの両方で)。
Logcatは言う:
エラー/AndroidRuntime(18754):android.util.AndroidRuntimeException:アクティビティコンテキストの外部からstartActivity()を呼び出すには、FLAG_ACTIVITY_NEW_TASKフラグが必要です。これは本当にあなたが望むものですか?
(ペーストビン上のLogcat全体)
ここに、アクティビティが定義されているマニフェストの部分があります。
<activity android:name=".KeygenAct">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
テストコード全体(問題を見つけるために不可欠なものに関する私のプロジェクトです)は、googlecode(http://code.google.com/p/cleanproject/source/browse/)(Eclipse-Project)で見つけることです。
助けてくれてありがとう、エセンティアン
ps:keygenはキージェネレーターではなく、より多くのkey_generalを意味します。少し巧妙に表現されていません;)