Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

when the device internet does not work (or is turned off) exits the program. (Jsoup)

JSOUP

when the device internet does not work (or is turned off) exits the program.

but it works without problems (without app crash) while the internet is running.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

if the program enters this coded part of the program without the Internet, the program will crash. the program should not crash when I access this coded part without internet. just a toast message that the internet is not available is enough. how can i do?

EDIT:

the problem is when I don’t add a toast message.

>Solution :

If what you’re looking for is just a message that the request couldn’t be completed normally, it should be enough to change the catch block a bit:

        try {

            Document doc = (Document) Jsoup.connect("(warn: here my web)").get();
            test1 = doc.text();
        } catch (Exception e) {
            // TODO your error message here
            test1 = "An exception occurred and it wasn't possible to get the document";
            // TODO use a logging framework!
            e.printStackTrace();
        }
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading