This is probably a trivial question for experienced devs, but since I’m comming from PHP I’m struggling with the following problem:
I’m starting an activity. First thing it does ( in onCreate() ) is checking if a network connection is available. If not, I’m showing a dialog. So far it’s working. However, in that case, I’d like to stop the startup-routine (onCreate, onResume, …). How can I do that?
I’ve now changed my approach to putting everything in try/catch constructs, but many functions throw the same IOException error – how can I distinguish and show the appropriate message/dialog ? (eg: no wifi/3g available, no http connection possible, downloaded file is empty etc) ?
I’ve looked for tutorials but haven’t found any that go more in detail but the obvious “try/catch” explanation…
Move code from onCreate() to separate method ex.
init(). Test network connection in onCreate(), when passed invokeinit(), if not –finish().