In an attempt to write a custom Android sync adapter I followed this. I was success at showing an entry (Account settings) in General setting with the following code snippet from above said example.
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="General Settings" />
<PreferenceScreen android:key="account_settings"
android:title="Account Settings" android:summary="Sync frequency, notifications, etc.">
<intent android:action="fm.last.android.activity.Preferences.ACCOUNT_SETUP"
android:targetPackage="fm.last.android"
android:targetClass="fm.last.android.activity.Preferences" />
</PreferenceScreen>
</PreferenceCategory>
</PreferenceScreen>
The code resulted me an entry (Account Settings) in General settings:
Upon clicking the Account Settings I'm getting an error as follows and the device reboots unnecessarily.
ERROR/AndroidRuntime(30057): android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
I know this error can be solved through code. Since "Account Settings" preference is XML-based code I'm stuck with the error.
Can anyone help to solve the Issue?
How do we control these kind of preferences through code?