I am using reCaptcha API on android through SafetyNet API as given on Android Developer site. My application is multilingual application. When I all together change phones language setting, my reCaptcha appears in that language. But I want to change language according to selected locale on app level without changing phone language settings. Google docs has given language codes here. Can anyone help me with implementing this thing. Any help or any suggestion will be appreciated.
This is my current code. This works with default phone language very well. I explored available methods for specifying language but no luck.
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();
}
});
}