First of all, I have almost no experience in Java. I'm using AsyncTask
to get some data from my server and in the onPostExecute
method I need to use several try-catch blocks to manage the received data. If one of them fails (catch is executed) the app should stop execution and show a dialog. But when any catch block is executed, the following try-catch blocks are executed, and that's what I want to avoid. I can't use return
because onPostExecute
returns void.
So, what is the best way to manage this situation to achieve what I need?
If a Method returns Void, you can use "return;" to exit the method.
So in the Catch block, Show the Dialogand Exit with return;
Elsewhere you can catch different exceptions in one try block.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.