Skip to content
Advertisement

App crashes when connection is lost while using HttpUrlConnection

i’m making a class that get json data from an external url, it is working fine if there is a connection. also shows an error if there isn’t. the problem is if the connection lost while the class is getting data the app crashes.

here is my code:

JavaScript

so guys is there any solution to prevent the app from crashing?

Advertisement

Answer

Set timeout on request by example:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement