I am trying to create a dialog preference as follows
<DialogPreference
android:key="cachePref"
android:dialogMessage="Testing message"
android:dialogTitle="Title Test"
android:positiveButtonText="positive"
android:summary="Clear images save to disk"
android:title="Clear Image Cache" />
But when the activity runs it force closes with the following error
11-01 01:21:18.820: E/AndroidRuntime(19644): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bakasura/com.bakasura.SettingsPreferences}: android.view.InflateException: Binary XML file line #71: Error inflating class java.lang.reflect.Constructor
This looks like Android Issue 3972: InstantiationException when using DialogPreference:
DialogPreferencealways was an abstract class and as such it should not have been able to be instantiated — but a bug in reflection code allowed to do so anyway up to Android 1.6. After that, it correctly throws an exception.A work around is to create a custom class extending
DialogPreferenceand use that instead as suggested in comment 9 of the issue.