June 21, 2019
(Note: if you are using Flutter, please see our hCaptcha Flutter guide.)
2021 Update
The article below is now outdated: please use our native Android SDK.
Simply create an HTML file with a hCaptcha form (see hCaptcha docs) and host that on your web site. Then load the URL in a WebView and create a bridge between Java and Javascript (addJavascriptInterface).
Android Activity:
Note: if you are an hCaptcha Enterprise customer, you can also embed the HTML file directly into your mobile app.
in your Activity instead becomes:
Contact the integration engineering team for further guidance to enable this.
Bridge Class:
Now from your HTML file you can run the Bridge Class as a Javascript function:
Finally, pass the response token returned above to your backend server, and have it call siteverify to check that the token is valid.
Let us if you have any questions!
Credit: this method was inspired by a similar StackOverflow answer.