简体   繁体   中英

can't figure out why i am getting “uncaught handler”

I keep getting uncaught handler error in this code and I don't know why. I have another app with almost identical code and it doesn't crash but this one does. Can anyone help?

public class myActivity extends Activity {
WebView mWebView;
    /** Called when the activity is first created. */
     public void onCreate(Bundle savedInstanceState) {

             super.onCreate(savedInstanceState);
             setContentView(R.layout.main);
      //       
             mWebView = (WebView) findViewById(R.id.webview);
             mWebView.getSettings().setJavaScriptEnabled(true);
             mWebView.loadUrl("http://www.mysite.com/index.htm");
             // on touch listener
             mWebView.setOnTouchListener(new OnTouchListener() {
                       public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
                         }

                    @Override
                    public boolean onTouch(View v, MotionEvent event) {
                        //the action goes in here
                        Bitmap mBitmap = mWebView.getDrawingCache();
                        mWebView.setDrawingCacheEnabled(true);
                    try {
                        myActivity.this.setWallpaper(mBitmap);
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                    return false;
                        }; //end on touch listener

             });
             registerForContextMenu(mWebView);   
           }

I fixed it by putting

mWebView.setDrawingCacheEnabled(true);

Before

Bitmap mBitmap = mWebView.getDrawingCache();

It makes sense to enable cache and then get cache instead of the other way around :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM