i am disabling orientation change in my app. i need to enable it only when user tap on any edittext.there are some edittexts in my webview. i have added below code to do the same.
mWebView.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
WebView.HitTestResult hr = ((WebView)v).getHitTestResult();
if(hr!=null){
if(hr.getType()==HitTestResult.EDIT_TEXT_TYPE )
((Activity) context).setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
else
((Activity) context).setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
return false;
}
});
In android 4.0 device it is working fine. But in 2.2 OS hr.getType() returns unknown_type ie 0. how can i make it work in older versions too...