Issue
Resources was deprecated in API level 25, How can I modify it now?
public Resources getResources(Resources resources) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
Configuration config = resources.getConfiguration();
Locale locale = LanguageSetting.getLanguage(activity);
config.setLocale(locale);
DisplayMetrics metrics = resources.getDisplayMetrics();
return new Resources(activity.getAssets(), metrics, config);
} else {
return resources;
}
}
Solution
Remove the condition that checks if the device android OS is less than N. Here: if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {.
That warning and the deprecation line should disappear.
Your code should now look like this:
public Resources getResources(Resources resources) {
Configuration config = resources.getConfiguration();
Locale locale = LanguageSetting.getLanguage(activity);
config.setLocale(locale);
DisplayMetrics metrics = resources.getDisplayMetrics();
return new Resources(getActivity().getAssets(), metrics, config);
}`
Answered By - devmike01
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.