Java tutorial
//package com.java2s; //License from project: Open Source License import android.annotation.TargetApi; import android.text.Html; import android.text.Spanned; import static android.os.Build.VERSION_CODES.N; public class Main { @TargetApi(N) public static Spanned fromHtml(String source) { if (isCompatible(N)) { return Html.fromHtml(source, Html.FROM_HTML_MODE_LEGACY); } else { return Html.fromHtml(source); } } public static boolean isCompatible(int apiLevel) { return android.os.Build.VERSION.SDK_INT >= apiLevel; } }