0

In my application, I am getting a number that should be greater than zero to proceed with further steps. That value is coming from service. Sometimes it will be negative or zero from service response. So I am checking it with the below code but the app crashes when it is a negative value. The crash happens at the line

if(expiry_num>0)

. Please help me on this

String expiry =StatusInfo.get("Minutes").toString();
           int expiry_num = Integer.parseInt(expiry);
            if (expiry_num>0) {


                    DetailsHandling();
                }
Malhotra
  • 221
  • 3
  • 13
  • I don't think the `if` is causing the crash, maybe the service is returning a string that can't be converted to a number and the `parseInt` is throwing the exception. Post the full stack trace please. – Ravi K Thapliyal Aug 14 '21 at 16:13
  • @RaviKThapliyal I tried to debug the code. It's happening in if. and service returning a number not string – Malhotra Aug 14 '21 at 16:27
  • Post the full stack trace please, `if` cannot throw an exception. It's likely that your source code is out of sync, happens when you're testing on a different sdk version than what you have downloaded source code for. – Ravi K Thapliyal Aug 14 '21 at 16:35

0 Answers0