So, I have the following code:
try{
....
if(serverResp.isSucces()){
callbackListener.onDataLoaded(serverResp);
}
}catch(Exception e){
//...do whatever I have to
}finally{
urlConnection.disconnect();
}
My question is, when the urlConnection.disconnect is being called? Most of the examples with finally explains when its called in case of return. I understand that case, but here I don't have return but to call to a listener. In most cases the listener callback triggers a new Activity to start. I would like to be sure, that all my previous connections are closed down!
So the main question is:
- When the finally get's called, if there is no return but listener callback?
- Is this a proper way to close the urlConnection?