Java tutorial
//package com.java2s; import android.text.TextUtils; public class Main { public static boolean isOTPOK(String otp_code) { if (TextUtils.isEmpty(otp_code)) { return false; } return TextUtils.isDigitsOnly(otp_code) && (otp_code.length() == 4); } }