android - Checking for getActivity() == null on user action -


whenever of our fragments asynchronous response network request, check whether getactivity() == null if have touch activity or use context.

so our code flow looks this:

protected void onnetworkresponse(string response) {    if (getactivity() == null)          return;    getactivity().setprogressbarvisibility(false);     // rest of processing here  } 

this makes sense (please comment if we're doing wrong! :) ). however, check getactivity() == null on user feedback, in onclicklistener, if we're going reference activity. me seems we're being overly cautious, because definition if button on fragment clicked, had attached activity. being overly cautious?


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -