1

我正在通过Android Developer 网站上给出的SafetyNet API在 android 上使用 reCaptcha API。我的应用程序是多语言应用程序。当我一起更改手机语言设置时,我的 reCaptcha 会以该语言显示。但我想根据应用程序级别的选定区域设置更改语言,而不更改手机语言设置。谷歌文档在这里给出了语言代码。谁能帮我实现这件事。任何帮助或任何建议将不胜感激。

这是我当前的代码。这非常适用于默认电话语言。我探索了指定语言的可用方法,但没有运气。

public void verify() {
        SafetyNetClient client = SafetyNet.getClient(activity);
        Task<SafetyNetApi.RecaptchaTokenResponse> verifierTask = client.verifyWithRecaptcha(activity.getResources().getString(R.string.site_key));
        verifierTask.addOnSuccessListener(activity, new OnSuccessListener<SafetyNetApi.RecaptchaTokenResponse>() {
                    @Override
                    public void onSuccess(SafetyNetApi.RecaptchaTokenResponse recaptchaTokenResponse) {
                        String userResponseToken = recaptchaTokenResponse.getTokenResult();
                        if (!userResponseToken.isEmpty()) {
                            new CaptchaVerificationTask().execute(userResponseToken);
                        } else {
                            captchaVerificationListener.onFailure();
                        }
                    }
                }
        ).addOnFailureListener(activity, new OnFailureListener() {
            @Override
            public void onFailure(@NonNull Exception e) {
                if (e instanceof ApiException) {
                    // An error occurred when communicating with the
                    // reCAPTCHA service. Refer to the status code to
                    // handle the error appropriately.
                    ApiException apiException = (ApiException) e;
                    int statusCode = apiException.getStatusCode();
                    Log.d("Login ReCaptcha", "Error: " + CommonStatusCodes
                            .getStatusCodeString(statusCode));
                } else {
                    // A different, unknown type of error occurred.
                    Log.d("Login ReCaptcha", "Error: " + e.getMessage());
                }
                captchaVerificationListener.onFailure();
            }
        });
    }
4

0 回答 0