Issue
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.
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();
}
Answered By - geco17
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.