views:

88

answers:

0

Hi Guys! I made a custom component which simple extends a WebView

This component is used into activities that are loaded from a tabhost.

This component creates a timertask too.

I'd like to execute the task only if the activity that contains the component is visible.

Ex:

public class MyWebView extends WebView {
public MyWebView(Context context, AttributeSet as) {

    super(context,as);

    /** More code **/


        TimerTask ttask  = new TimerTask() {

            @Override
            public void run() {

                if (iamvisible)
                  doStuff();
            }
        };

        timer = new Timer();
        timer.schedule(ttask, refreshInterval * 1000, refreshInterval * 1000);

}
}

How can I set the iamvisible variable?

I tried overriding onWindowFocusChanged and onWindowVisibilityChanged but with no luck

Regards in advance