无法弄清楚为什么我会得到“未被捕获的处理程序”

时间:2011-02-24 18:52:19

标签: android handler

我在这段代码中一直出现uncaught handler错误,我不知道为什么。我有另一个应用程序与几乎相同的代码,它不崩溃,但这一个。有人可以帮忙吗?

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);   
           }

1 个答案:

答案 0 :(得分:1)

我把它修好了

mWebView.setDrawingCacheEnabled(true);

之前

Bitmap mBitmap = mWebView.getDrawingCache();

启用缓存然后获取缓存而不是相反的方式是有意义的:)