Alipay+ DocsAlipay+ Docs

TokenStatusListener

Call the TokenStatusListener API to monitor wallet status changes.

Method Signature

copy
class TokenStatusListener() {
    void onTokenLocked(boolean isSuccess, @Nullable String errorCode);
    void onTokenUnLocked(boolean isSuccess, @Nullable String errorCode);
    void onTokenDelete(@Nullable String reason);
}
// Listening Callback
ACTapManager.getInstance(context).setTokenStatusListener(TokenStatusListener())

Request parameters

Item

Type

Parameters

Description

onTokenLocked()

Function

boolean isSuccess

String errorCode

Called when a card is locked. For more information, see Result codes.

onTokenUnLocked()

Function

boolean isSuccess

String errorCode

Called when a card is unlocked. For more information, see Result codes.

onTokenDelete()

Function

String reason

Called when a card is deleted.

Response parameters

N/A

Sample

copy
class Demo implements TokenStatusListener {
    @Override
    public void onTokenLocked(boolean isSuccess, @Nullable String errorCode) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                AlertDialog alertDialog = new AlertDialog.Builder(ActivateCardActivity.this).create();
                alertDialog.setTitle(isSuccess ? getString(R.string.nfc_lock_success) : getString(R.string.nfc_lock_fail));
                alertDialog.setMessage(getString(R.string.error_code) + errorCode);
                alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, getString(R.string.button_ok),
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                dialog.dismiss();
                            }
                        });
                alertDialog.show();
            }
        });
    }

    @Override
    public void onTokenUnLocked(boolean isSuccess, @Nullable String errorCode) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                AlertDialog alertDialog = new AlertDialog.Builder(ActivateCardActivity.this).create();
                alertDialog.setTitle(isSuccess ? getString(R.string.nfc_unlock_success) : getString(R.string.nfc_unlock_fail));
                alertDialog.setMessage(getString(R.string.error_code) + errorCode);
                alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, getString(R.string.button_ok),
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                dialog.dismiss();
                            }
                        });
                alertDialog.show();
            }
        });
    }
}