I have a custom View that runs a Thread operation which sits around making calls to the interwebs periodically. I would like to know if there\'s a way for me to not have to kil
Yes you can using below code,
@Override
protected void onVisibilityChanged(@NonNull View changedView, int visibility) {
super.onVisibilityChanged(changedView, visibility);
if (visibility == View.VISIBLE) //onResume called
else // onPause() called
}
@Override
public void onWindowFocusChanged(boolean hasWindowFocus) {
super.onWindowFocusChanged(hasWindowFocus);
if (hasWindowFocus) //onresume() called
else // onPause() called
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
// onDestroy() called
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
// onCreate() called
}