Android obsolete method replacement

Recently, the company code quality inspection has revealed the use of many outdated methods. Record:

1.fromHtml

replace:

if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
    content.setText(Html.fromHtml(html.replaceAll("span style", "font color").replaceAll("span", "font").replaceAll("color:", ""),Html.FROM_HTML_MODE_LEGACY));
} else {
    content.setText(Html.fromHtml(html.replaceAll("span style", "font color").replaceAll("span", "font").replaceAll("color:", "")));
}

2.new Date(.toLocaleString())

replace:

SimpleDateFormat sdf = (SimpleDateFormat) DateFormat.getDateTimeInstance();
sdf.format(new Date()
 

Guess you like

Origin blog.csdn.net/u010256329/article/details/100879322