Only want to block orientation until all the data is loaded in my view. So I thought about the following code but it doesn\'t work.
private class task extends As         
        
Just replace setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); with setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
And let me know what happen..
For Entry Level
 protected void onPreExecute() {
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
}
At Exit Level
 protected void onPostExecute(String result) {
      ...
     setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
   }
Update:
Wired behavior (In your case) but, any way you can get the current orientation using,
int currentOrientation = getResources().getConfiguration().orientation; 
Now set this orientation in onPreExecute() .. 
Like,
protected void onPreExecute() {
  ...
  int currentOrientation = getResources().getConfiguration().orientation; 
   if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
   }
   else {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
   }
}
Simple.. :-)