> >

SenseBot Android API Document

GT3GeetestUtils

API document of SenseBot

Method

GT3GeetestUtils(Context)

Object for developer

Declaration

public GT3GeetestUtils(Context context)

Parameters

Param Type Description
context Context context

init(GT3ConfigBean bean)

captcha Initialization

Declaration

public void init(GT3ConfigBean bean)

Parameters

Param Type Description
bean GT3ConfigBean Configure bean

startCustomFlow()

Start captcha verification

Declaration

public void startCustomFlow()

getGeetest()

Continue captcha verification flow

Declaration

public void getGeetest()

dismissGeetestDialog()

Close the captcha dialog

Declaration

public void dismissGeetestDialog()

showSuccessDialog()

Show the “Verification Succeeded” prompt

Declaration

public void showSuccessDialog()

Discussion

When receive the result of secondary verification, if the verification succeeded, call this method.

showFailedDialog()

Show the “Verification failed” prompt

Declaration

public void showFailedDialog()

Discussion

When receive the result of secondary verification, if the verification failed, call this method.

getVersion()

Get the SDK version

Declaration

public String getVersion()

Return Value

Return the SDK version. Type: String

destory()

Free memory

Declaration

public void destory()

Discussion

Please call this method in the lifecycle of onDestroy

changeDialogLayout()

Screen rotation

Declaration

public void changeDialogLayout()

Discussion

Please call this method in the lifecycle of onConfigurationChanged.

GT3ConfigBean

Configuration class

setApi1Json(JSONObject)

Set the API1 returned data

Declaration

public void setApi1Json(JSONObject json)

Parameters

Param Type Description
json JSONObject The returned data when API1 is called

Discussion
This method is used to configure the returned data of API1. The following is an example of json.

{
"success" : 1,
"challenge" : "4a5cef77243baa51b2090f7258bf1368",
"gt" : "019924a82c70bb123aae90d483087f94",
}

The successchallenge and gt are default variables. Please do NOT delete or remove any of them. You can add more variable.

setTimeout(int)

Set duration of captcha loading timeout in millisecond. Default value is 10000.

Declaration

public void setTimeout(int time)

Parameters

Param Type Description
time int Time in milliseconds, e.g. 10000

setWebviewTimeout(int)

Duration of request in Webview timeout in millisecond. Default value is 10000.

Declaration

public void setWebviewTimeout(int time)

Parameters

Param Type Description
time int Time in milliseconds, e.g. 10000

setLang(String)

Set the language for captcha.

Declaration

public void setLang(String lang)

Parameters

Param Type Description
lang String “zh”–Chinese (Simplified), “zh-tw”–Chinese (Taiwan), “zh-hk”–Chinese (Hong Kong), “en”–English, “id”– Indonesian, “ja”– Japanese, “ko”– Korean, “ru”– Russian, “ar”– Arabic, “es”– Spanish, “pt-pt”– Portuguese, “fr”– French, “de”– German, “th”– Thai, “tr”– Turkish, “vi”– Vietnamese, “ta”– Tamil, “it”– Italian, “bn”– “Bengali”, “mr”– Marathi. If the lang is null or it hasn’t been configured, the CAPTCHA will present in the system default language.

Discussion
If the captcha use unbind mode, please call the init before setContentView, then the language modification could be activated immediately.

setCanceledOnTouchOutside(boolean)

Get canceled when touch outside the captcha challenge window. Default value is false.

Declaration

public void setCanceledOnTouchOutside(boolean cancel)

Parameters

Param Type Description
cancel boolean true refers to disappear

setUnCanceledOnTouchKeyCodeBack(boolean)

Set whether the pop-up box disappears by clicking the back button, and disappears by default

Declaration

public void  setUnCanceledOnTouchKeyCodeBack(boolean cancel)

Parameters

Param Type Description
cancel boolean true means not disappear, false means disappear

setPattern(int)

Set bind/unbind mode,1 is bind,2 is unbind

Declaration

public void setPattern(int pattern)

Parameters

Param Type Description
pattern int 1为bind,2为unbind

setGt3ServiceNode(GT3ServiceNode)

Set server node before using it. The default is CN.

Declaration

public void  setGt3ServiceNode(GT3ServiceNode gt3ServiceNode)

Parameters

Param Type Description
gt3ServiceNode GT3ServiceNode enum,NODE_CHINA or NODE_NORTH_AMERICA

setGTViewWithParams(Map<String,String>)

Set parameters for frontend

Declaration

public void  setGTViewWithParams(Map<String,String> map)

Parameters

Param Type Description
map Map<String,String> Pass in the map format. Then SDK will parse it into form and attach to the request URL

setLoadImageView(GT3LoadImageView)

Customized loading image

Declaration

public void setLoadImageView(GT3LoadImageView loadImageView)

Parameters

Param Type Description
loadImageView GT3LoadImageView Self-define loading

Discussion

Inherit from GT3LoadImageView then set to GT3ConfigBean

setListener(GT3Listener)

Set the listener

Declaration

public void setListener(GT3Listener listener)

Parameters

Param Type Description
listener GT3Listener GT3Listener is the listener object

setCorners(int)

Set the radius of the rounded corner of the verification View, in unit dp

Declaration

public void setCorners(int radius)

Parameters

Param Type Description
radius int dg: 12

setReleaseLog(boolean)

Sets whether log writing is turned off. Default is true

Declaration

public void  setReleaseLog(boolean release)

Parameters

Param Type Description
release boolean True to load logs locally for writing CAPTCHA. Default is FASLE

GT3Listener

Callback the Listener

onDialogReady()

Captcha has been loaded successfully

Declaration

public void onDialogReady(String duration)

Parameters

Param Type Description
duration String Load time, version and so on in json format.

onReceiveCaptchaCode()

Graph validation results callback

Declaration

public void onReceiveCaptchaCode(int i)

Parameters

Param Type Description
i int 1 is normal and 0 is failure

onClosed(int)

Captcha has been closed.

Declaration

public void onClosed(int  num)

Parameters

Param Type Description
num int 1 refer to click at the close button in the captcha; 2 click at the screen to close the captcha; 3 click at the back button to close the captcha

onDialogResult(String)

Get the verification result callback.

Declaration

public void onDialogResult(String result)

Parameters

Param Type Description
result String Verification result

Discussion

The secondary verification require geetest_challengegeetest_validategeetest_seccode. Please do NOT delete or remove any of them. You can add more variables.

onSuccess(String)

Return value if the verification succeeded.

Declaration

public void onSuccess(String result)

Parameters

Param Type Description
result String Return value if the verification succeeded.

onFailed(GT3ErrorBean)

Return value if the verification failed.

Declaration

public void onFailed(GT3ErrorBean errorBean)

Parameters

Param Type Description
errorBean GT3ErrorBean Return value if the verification failed.

Discussion

Please find the details about error code in the error code session.

onButtonClick()

The captcha button has been clicked and the verification flow will start.

Declaration

public void onButtonClick()

Discussion

This method is used to listen if the captcha button has been click.

actionBeforeDialogShow()

Callback before the dialog show method executes

Declaration

public void actionBeforeDialogShow(Dialog dialog)

Discussion

This method is used to hide the navigation bar when the dialog is displayed

@Override
public void actionBeforeDialogShow(Dialog dialog) {
dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
}

actionAfterDialogShow()

Callback after the dialog show method executes

Declaration

public void actionAfterDialogShow(Dialog dialog)

Discussion

This method is used to hide the navigation bar when the dialog is displayed

@Override
public void actionAfterDialogShow(Dialog dialog) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_FULLSCREEN;
dialog.getWindow().getDecorView().setSystemUiVisibility(uiOptions);
}
dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
}

onWindowFocusChanged()

Callback when the Dialog onWindowFocusChanged method is executed

Declaration

public void onWindowFocusChanged(Dialog dialog, boolean hasFocus)

Discussion

This method is used to hide the navigation bar when the dialog is displayed

GT3GeetestButton

Custom button of captcha in unbind mode

Method

setGeetestUtils(GT3GeetestUtils)

Set the object for GT3GeetestUtils.

Declaration

public void setGeetestUtils(GT3GeetestUtils geetestUtils)

Parameters

Param Type Description
geetestUtils GT3GeetestUtils Association

Discussion

Associate GT3GeetestUtils with GT3GeetestButton

GT3LoadImageView

Custom loading icon in bind mode.

Method

isGif()

The return value is a GIF or not. Default value is true, which refers to the return value is GIF. The false refer to custom view.

Declaration

public boolean isGif()

Discussion

To custom the loading icon, please set the width and height.

setIconRes(int)

Set GIF resource. When isGif returns true, the setting will be activated.

Declaration

public void setIconRes(int iconRes)

Parameters

Param Type Description
iconRes int Resource ID

Discussion

Set GIF resource. When isGif returns true, the setting will be activated.

setLoadViewWidth(int)

Set the width of icon

Declaration

public void setLoadViewWidth(int loadViewWidth)

setLoadViewHeight(int)

Set the height of icon

Declaration

public void setLoadViewHeight(int loadViewHeight)

execute()

Pre-processing the method. Preprocess before loading the icon, e.g. loading animation

Declaration

public void execute()

Discussion

If the icon is not in gif format, override isGif() and it will return false. Then, override the onDraw() and other methods. Please refer the demo for the details.

Was this helpful?
Send