public void onConfigurationChanged(Configuration newConfig) {
   int orientation = activity.getResources().getConfiguration().orientation;
   if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
     hideSoftInput();
     Window win = activity.getWindow();
     win.setSoftInputMode(
         WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN
             | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
     rlPage.setBackgroundColor(DIM_COLOR);
     rlPage.postDelayed(
         new Runnable() {
           public void run() {
             genBackground();
             rlPage.setBackgroundDrawable(background);
           }
         },
         1000);
   } else {
     hideSoftInput();
     Window win = activity.getWindow();
     win.setSoftInputMode(
         WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE
             | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
     rlPage.setBackgroundColor(DIM_COLOR);
     rlPage.postDelayed(
         new Runnable() {
           public void run() {
             genBackground();
             rlPage.setBackgroundDrawable(background);
           }
         },
         1000);
   }
 }
 public boolean onFinish() {
   hideSoftInput();
   return super.onFinish();
 }