w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Android - How to Handle an Async Http Crash

I can see that you are already catching the Exceptions and have a String as parameter type to onPostExecute. From inside the exceptions, you can pass a string like "error" to the onPostExecute, whenever an error occurs. Inside the onPostExecute you can check:

if the string is equal to "error":
    then create a Alert dialog box from within `onPostExecute` and show it.

    continue as desired

Ideally a boolean would do the trick but since you already have a string, you can also use that. Otherwise you can have a struct with a string and a boolean and then pass it to onPostExecute. Hope it gives you the idea.

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.