Reputation: 159
I have a problem trying to use preferences with my App. I could not find a solution in similar posts here. My App shall support android versions from 8 to 19. With Android Developer I found this:
If your app supports versions of Android older than 3.0 (API level 10 and lower), you must build the activity as an extension of the PreferenceActivity class. On Android 3.0 and later, you should instead use a traditional Activity that hosts a PreferenceFragment that displays your app settings. However, you can also use PreferenceActivity to create a two-pane layout for large screens when you have multiple groups of settings.
So what to do if I would not support neither API's up to level 10 and not higher nor API's only higher than 10?
I have tried to use the PreferenceActivity class together with addPreferencesFromRessource(R.id....) But than I've got this:
package com.example.wbslideshow;
import android.os.Bundle;
import android.preference.PreferenceActivity;
public class initialpath extends PreferenceActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
}
}
where addPreferencesFromResource is seen as addPreferencesFromResource because of the deprecated status.
together with this explanation:
The method addPreferencesFromResource(int) from the type PreferenceActivity is deprecated
What can I do? I think due to my API's level I can not use also PreferenceFragment which I would like to prefer. Any idea is appreciated.
Upvotes: 0
Views: 872
Reputation: 434
Use the deprecated functions. They are still working but should not be considered state of the art. There is no option since you want to support older versions without the new possibilities. You could think about switching your project to newer APIs only.
Upvotes: 1