AuthUiConfig authConfig = new AuthUiConfig();authUiConfig.setAuthCircleCorrectColor(resources.getColor(R.color.demo_blue));huiYanOsConfig.setAuthUiConfig(authConfig);

<?xml version="1.0" encoding="utf-8"?><com.tencent.could.huiyansdk.view.HuiYanReflectLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"android:id="@+id/txy_auth_layout_bg"android:layout_width="match_parent"android:layout_height="match_parent"><!-- 取消按钮 --><TextViewandroid:id="@+id/txy_cancel_txt_btn"android:text="@string/txy_cancel"android:layout_width="wrap_content"android:layout_height="wrap_content"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toTopOf="parent"android:textColor="@color/txy_black"android:textSize="@dimen/txy_tips_extra_text_size"android:layout_marginTop="@dimen/txy_title_margin_top"android:layout_marginStart="@dimen/txy_protocol_margin_size"/><!-- 倒计时的显示控件 --><TextViewandroid:id="@+id/txy_count_down_txt_view"android:text="@string/txy_count_down_txt"app:layout_constraintTop_toTopOf="parent"app:layout_constraintEnd_toEndOf="parent"android:textSize="@dimen/txy_tips_extra_text_size"android:textColor="@color/txy_black"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginTop="@dimen/txy_title_margin_top"android:layout_marginRight="@dimen/txy_protocol_margin_size"android:visibility="gone"/><!-- 摄像头预览界面框 720P的话,代码中height会自定乘以1.3 --><com.tencent.could.huiyansdk.view.CameraDateGatherViewandroid:id="@+id/txy_camera_gather_view"android:layout_width="@dimen/txy_auth_head_size"android:layout_height="@dimen/txy_auth_head_default_height"android:background="@android:color/transparent"android:layout_marginBottom="@dimen/txy_auth_view_move"app:layout_constraintBottom_toBottomOf="parent"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toTopOf="parent" /><!-- 通用背景,待竖线的圆环 --><com.tencent.could.huiyansdk.view.CommonAuthBackViewandroid:id="@+id/txy_auth_common_background_views"android:layout_width="@dimen/txy_auth_circle_size"android:layout_height="@dimen/txy_auth_circle_size"android:layout_marginBottom="@dimen/txy_auth_view_move"app:layout_constraintBottom_toBottomOf="parent"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toTopOf="parent"/><!-- 展示的头像图片 --><ImageViewandroid:id="@+id/txy_camera_prepare_img"app:srcCompat="@drawable/txy_prepare_face_head_white"android:layout_width="@dimen/txy_auth_head_size"android:layout_height="@dimen/txy_auth_head_size"android:layout_marginBottom="@dimen/txy_auth_view_move"app:layout_constraintTop_toTopOf="parent"app:layout_constraintBottom_toBottomOf="parent"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintStart_toStartOf="parent" /><!-- 前台的动画View --><com.tencent.could.huiyansdk.view.LoadingFrontAnimatorViewandroid:id="@+id/txy_auth_loading_front_animator_view"android:visibility="gone"app:layout_constraintTop_toTopOf="parent"app:layout_constraintBottom_toBottomOf="parent"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintStart_toStartOf="parent"android:layout_marginBottom="@dimen/txy_auth_view_move"android:layout_width="@dimen/txy_auth_head_size"android:layout_height="@dimen/txy_auth_head_size"/><!-- 提示信息的展示界面 --><TextViewandroid:id="@+id/txy_auth_feed_back_txt"app:layout_constraintTop_toBottomOf="@id/txy_auth_common_background_views"app:layout_constraintStart_toStartOf="parent"app:layout_constraintEnd_toEndOf="parent"android:textColor="@color/txy_black"android:layout_marginTop="@dimen/txy_protocol_line_space"android:text="@string/txy_face_preparing3"android:textSize="@dimen/txy_tips_text_size"android:paddingHorizontal="@dimen/txy_title_margin_top"android:gravity="center_horizontal"android:layout_width="wrap_content"android:layout_height="wrap_content"/><!-- 额外的警告信息的提示控件 --><TextViewandroid:id="@+id/txy_auth_feed_back_extra_tip_txt"android:textSize="@dimen/txy_tips_extra_text_size"android:textColor="@color/txy_black"android:layout_width="match_parent"android:layout_height="wrap_content"android:gravity="center_horizontal"android:paddingHorizontal="@dimen/txy_title_margin_top"app:layout_constraintStart_toStartOf="parent"app:layout_constraintEnd_toEndOf="parent"android:layout_marginTop="20dp"app:layout_constraintTop_toBottomOf="@id/txy_auth_feed_back_txt"/></com.tencent.could.huiyansdk.view.HuiYanReflectLayout>
// 这里设置慧眼关键事件的回调监听HuiYanOsApi.setAuthEventCallBack(new HuiYanAuthEventCallBack() {@Overridepublic void onAuthTipsEvent(HuiYanAuthTipsEvent tipsEvent) {Log.e(TAG, "current is : " + tipsEvent);}@Overridepublic void onMainViewCreate(View authView) {if (authView == null) {return;}// 获取自定义添加的控件,并且注册自定义的事件Button findBtn = authView.findViewById(R.id.add_view_offer_button);if (findBtn != null) {findBtn.setOnClickListener(view -> {Log.e(TAG, "click test button!");});}}@Overridepublic void onMainViewDestroy() {Log.e(TAG, "onMainViewDestroy");}});
hy_customer_string.xml里面包括了所有慧眼 SDK 对外可以进行修改的配置文件hy_customer_string.xml 添加到对应的语言文件夹下。
hy_customer_string.xml 拷贝到该语言文件夹下,并修改对应的 value 内容。
huiYanOsConfig.setLanguageStyle(LanguageStyle.CUSTOMIZE_LANGUAGE);huiYanOsConfig.setLanguageCode("th-TH");
invoke-custom are only supported starting with Android O (--min-api 26)错误?build.gradle 中添加如下配置:// java版本支持1.8compileOptions {sourceCompatibility JavaVersion.VERSION_1_8targetCompatibility JavaVersion.VERSION_1_8}
// for HuiYanSDK"R.string.ocr_*","R.string.rst_*","R.string.net_*","R.string.msg_*","R.string.fl_*",
android.content.res.Resources$NotFoundException:from xml type xml resource ID #0x7f0800c3 这一类的错误,可以考虑添加矢量图依赖:// 低版本的矢量图implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
android.content.res.Resources$NotFoundException: File res/drawable/$txy_face_id_logo__0.xml from color state list resource ID #0x7f070001at android.content.res.Resources.loadColorStateListForCookie(Resources.java:2800)at android.content.res.Resources.loadColorStateList(Resources.java:2749)at android.content.res.TypedArray.getColor(TypedArray.java:441)at android.content.res.XResources$XTypedArray.getColor(XResources.java:1286)at android.support.v4.content.res.TypedArrayUtils.getNamedColor(TypedArrayUtils.java:124)at android.support.graphics.drawable.VectorDrawableCompat$VFullPath.updateStateFromTypedArray(VectorDrawableCompat.java:1746)at android.support.graphics.drawable.VectorDrawableCompat$VFullPath.inflate(VectorDrawableCompat.java:1712)at android.support.graphics.drawable.VectorDrawableCompat.inflateInternal(VectorDrawableCompat.java:743)at android.support.graphics.drawable.VectorDrawableCompat.inflate(VectorDrawableCompat.java:631)at android.support.graphics.drawable.VectorDrawableCompat.createFromXmlInner(VectorDrawableCompat.java:590)at android.support.v7.widget.AppCompatDrawableManager$VdcInflateDelegate.createFromXmlInner(AppCompatDrawableManager.java:775)
implementation 'com.android.support:appcompat-v7:28.0.0'// 兼容低版本矢量图依赖的组件库implementation 'com.android.support:support-vector-drawable:28.0.0'implementation 'com.android.support:animated-vector-drawable:28.0.0'
语言码 | 对应使用的国家或地区 |
af-ZA | 公用荷兰语 - 南非 |
sq-AL | 阿尔巴尼亚 -阿尔巴尼亚 |
ar-DZ | 阿拉伯语 -阿尔及利亚 |
ar-BH | 阿拉伯语 -巴林 |
ar-EG | 阿拉伯语 -埃及 |
ar-IQ | 阿拉伯语 -伊拉克 |
ar-JO | 阿拉伯语 -约旦 |
ar-KW | 阿拉伯语 -科威特 |
ar-LB | 阿拉伯语 -黎巴嫩 |
ar-LY | 阿拉伯语 -利比亚 |
ar-MA | 阿拉伯语 -摩洛哥 |
ar-OM | 阿拉伯语 -阿曼 |
ar-QA | 阿拉伯语 -卡塔尔 |
eu-ES | 巴斯克 -巴斯克 |
be-BY | Belarusian -白俄罗斯 |
bg-BG | 保加利亚 -保加利亚 |
ca-ES | 西班牙-加泰罗尼亚语 |
zh-HK | 华语 - 中国香港 |
zh-MO | 华语 - 中国澳门 |
zh-CN | 华语 -中国 |
zh-SG | 华语 -新加坡 |
zh-TW | 华语 - 中国台湾 |
zh-CHS | 华语 (简体) |
zh-CHT | 华语 (繁体) |
hr-HR | 克罗埃西亚 -克罗埃西亚 |
cs-CZ | 捷克 - 捷克 |
da-DK | 丹麦文 -丹麦 |
div-MV | Dhivehi -马尔代夫 |
nl-BE | 荷兰 -比利时 |
nl-NL | 荷兰 - 荷兰 |
en-AU | 英语 -澳洲 |
en-CA | 英语 -加拿大 |
en-ZA | 英语 - 南非 |
en-PH | 英语 -菲律宾共和国 |
en-NZ | 英语 - 新西兰 |
en-GB | 英语 - 英国 |
en-US | 英语 - 美国 |
fa-IR | 波斯语 -伊朗王国 |
fi-FI | 芬兰语 -芬兰 |
fr-FR | 法语 -法国 |
fr-BE | 法语 -比利时 |
fr-MC | 法语 -摩纳哥 |
fr-CH | 法语 -瑞士 |
gl-ES | 加利西亚 -加利西亚 |
ka-GE | 格鲁吉亚 -格鲁吉亚语 |
de-DE | 德语 -德国 |
de-LU | 德语 -卢森堡 |
de-CH | 德语 -瑞士 |
el-GR | 希腊 -希腊 |
gu-IN | Gujarati -印度 |
he-IL | 希伯来 -以色列 |
hi-IN | 北印度语 -印度 |
hu-HU | 匈牙利语 -匈牙利 |
is-IS | 冰岛语 -冰岛 |
it-IT | 意大利 -意大利 |
ja-JP | 日本 -日本 |
kk-KZ | Kazakh -哈萨克 |
kn-IN | 卡纳达语 -印度 |
ko-KR | 韩国 -韩国 |
lv-LV | 拉脱维亚语 -拉脱维亚 |
lt-LT | 立陶宛 -立陶宛 |
ms-BN | 马来语 -文莱 |
ms-MY | 马来语 -马来西亚 |
mr-IN | 马拉地语 -印度 |
mn-MN | 蒙古 -蒙古 |
nn-NO | 挪威 (Nynorsk) - 挪威 |
pl-PL | 波兰 -波兰 |
pt-BR | 葡萄牙语 -巴西 |
pt-PT | 葡萄牙语 -葡萄牙 |
ro-RO | 罗马尼亚语 -罗马尼亚 |
sa-IN | 梵文 -印度 |
ru-RU | 俄国 -俄国 |
sk-SK | 斯洛伐克 -斯洛伐克 |
es-AR | 西班牙语 -阿根廷 |
es-ES | 西班牙语 -西班牙 |
sv-SE | 瑞典 -瑞典 |
th-TH | 泰国 -泰国 |
tr-TR | 土耳其语 -土耳其 |
uk-UA | 乌克兰 -乌克兰 |
ur-PK | Urdu -巴基斯坦 |
vi-VN | 越南 -越南 |
文档反馈