安卓应用中的验证码

5

我需要在我的Android应用程序代码中实现验证码,但不知道如何着手。

请问有人可以帮我吗?


请查看此链接:http://stackoverflow.com/a/41218856/6295668 - Jinesh Francis
3个回答

5

JCaptcha 可以肯定。我不知道 SimpleCaptcha,但它应该也可以。 - Amokrane Chentir

3

我很不要脸地自荐一下,但我讨厌其他所有的选择,特别是它们都是基于网络的。现在,我确定我的解决方案需要大量的工作等,并且可能没有使用其他外部解决方案那么安全,但至少它容易使用并具有一些选项。

在这里获取它,并享受改变和提交的乐趣


了不起的实现 - Pritish Joshi

2
现在,谷歌提供了SafetyNet reCAPTCHA库来解决这个问题。详情请查看此处
以下是实施reCaptcha的步骤:
  1. 添加SafetyNet API依赖项。
dependencies {
    compile 'com.google.android.gms:play-services-safetynet:15.0.1'
}
  1. Use API(example from google documentation)

    public void onClick(View v) {
    SafetyNet.getClient(this).verifyWithRecaptcha(YOUR_API_SITE_KEY)
        .addOnSuccessListener((Executor) this,
            new OnSuccessListener<SafetyNetApi.RecaptchaTokenResponse>() {
                @Override
                public void onSuccess(SafetyNetApi.RecaptchaTokenResponse response) {
                    // Indicates communication with reCAPTCHA service was
                    // successful.
                    String userResponseToken = response.getTokenResult();
                    if (!userResponseToken.isEmpty()) {
                        // Validate the user response token using the
                        // reCAPTCHA siteverify API.
                    }
                }
        })
        .addOnFailureListener((Executor) this, 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(TAG, "Error: " + CommonStatusCodes
                                .getStatusCodeString(statusCode));
                    } else {
                        // A different, unknown type of error occurred.
                        Log.d(TAG, "Error: " + e.getMessage());
                    }
                }
        });
    

    }


reCAPTCHA是一个相当不错的解决方案,但在移动设备上(如华为)没有GmsCore时可能会出现故障。 - Saint

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接