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 :)
精彩评论