Question

This is not deprecation-related. I get this error wherever I put the line addPreferencesFromResource(R.xml.preferences);, just after onCreate or in a seperate method called after.

I did include import android.preference.PreferenceActivity; but it shows up greyed as unused.

I'm using the latest Android Studio if it counts for something.

Was it helpful?

Solution

The compilation error occurs because you're extending Activity and not PreferenceActivity.

So replace

public class MainActivity extends Activity {

with

public class MainActivity extends PreferenceActivity {

and you should be good to go.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top