1、TextView显示多种颜色字体
SpannableStringBuilder style =
new SpannableStringBuilder("您的相机功能好像有问题哦~\n去“设置>隐私>相机”开启一下吧");
style.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.take_phone)), 15, 23, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
mContent.setText(style);
2、判断权限是否开启
permName --> 权限名; pkgName --> 应用包名
private static boolean checkPermission(Context context, String permName, String pkgName) {
PackageManager pm = context.getPackageManager();
if (PackageManager.PERMISSION_GRANTED == pm.checkPermission(permName, pkgName)) {
System.out.println(pkgName + "has permission : " + permName);
return true;
} else {
//PackageManager.PERMISSION_DENIED == pm.checkPermission(permName, pkgName)
System.out.println(pkgName + "not has permission : " + permName);
return false;
}
}