How can I put a timeout/(raise exception) on my if statement. I want to execute the if statement only if the isNetworkAvailable
method responds with in 2000 milliseconds otherwise raise an exception. Otherwise, I just want to know if the 2000 milliseconds have passed and ignore the if statement.
I would appreciate the help, thanks.
This is my if statement
if (networkUtils.isNetworkAvailable(context)) {
getToken = new GetToken(context);
getToken.getToken();
token = Token.getInstance();
}