android - Is there a workaround for when HttpURLConnection.getResponseCode throws NullPointerException? -


i'm getting lot of errors caused error explained here. happens on android 2.3 or below, when call getresponsecode of httpurlconnection, weird happens randomly (one of causes when use underscores on url, have seen work these on url).

i know first recommendation use apache library, found i.e. facebook sdk android uses too, , breaks frequently. debugged this, on facebook it's breaking on line 301 of class com.facebook.response:

if (connection.getresponsecode() >= 400) { //a nullpointerexceptions thrown here. 

what recommendation here? don't think feasible approach migrate facebook part use apache library, or if can't avoided , ignore error , let user retry, bad, not sure how other apps resolve this.

thanks time.

are sure connection isn't null?

you can catch nullpointerexception , treat entire attempt download failure , retry/giveup.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -