Question

I succeed in adding WebView into sherlock fragment.and it's run fine but when I see my logcat, I find a strange output:

12-08 19:08:49.360: I/Choreographer(1495): Skipped 44 frames!  The application may be doing too much work on its main thread.

it's like a loop and doesn't want stop!!

what's those frames & should I do something with it??

Is it a thread problem?

There is my code,maybe I'm making errors that's why my logcat come to explode

public class Schedule extends SherlockFragment {

    private WebView web_v;

    @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
            // TODO Auto-generated method stub
        View v= inflater.inflate(R.layout.fragment_schedule, container, false);
        web_v=(WebView)v.findViewById(R.id.webView_schedule);
        WebSettings web_sett=web_v.getSettings();
        web_sett.setJavaScriptEnabled(true);
        web_v.setWebViewClient(new MyWebClient());
        web_v.loadUrl("http://www.pcinpact.com/?skipua=1");



        v.setOnKeyListener(new OnKeyListener() {

            @Override
            public boolean onKey(View v, int keyCode, KeyEvent event) {
                // TODO Auto-generated method stub
                if(keyCode==KeyEvent.KEYCODE_BACK && web_v.canGoBack()){
                    web_v.goBack();
                    return true;
                }
                return false;
            }
        });
        return v;
        }

    private class MyWebClient extends WebViewClient{

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            // TODO Auto-generated method stub
            web_v.loadUrl(url);
            return true;
        }


    }
}

thanks in advance.

Was it helpful?

Solution

Please remove the call to loadUrl() inside shouldOverrideUrlLoading, and just return false from this function.

The problem is that you are calling back out to tell the webview to restart loading the URL from scratch, from wihtin the callback to tell you the WebView would like to load a URL, resulting in a loop of requests to load the URL.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top