title: Android webview onBackPressed not fired when WebView is focused
body: <p>I have an activity, with a webView(Chromium webView <a href="https://github.com/mogoweb/chromium_webview/" rel="nofollow noreferrer">https://github.com/mogoweb/chromium_webview/</a>) inside it.</p>
  
  <p>The screen has two parts, top part is a ViewPager and bottom is a WebView. When the activity is loaded and webView is not in focus, back key works as expected and onBackPressed and onKeyDown are fired.</p>
  
  <p>However, the moment webView receives focus(by tapping or focusing a textfield), the activity doesn't seem to treat back key as expected and both onBackPress and onKeyDown are not fired.</p>
  
  <p>Things I have tried:
  - I have tried both onBackPress and onKeyDown.
  - Tried setting android:descendantFocusability="blocksDescendants" for the linearlayout, but webView doesn't receive focus anymore.</p>
  
  <p>I believe most of the code is standard java and since the events fire when webView is not in focus, I assume there is something I am not handling well when it comes to focusing a webView.</p>
  
  <p>The activity is a "Fragment Activity"</p>
  
  <p>Any suggestions are highly appreciated.?
  Following is the code for backpress and keydown, and even the debug messages are not to be seen and no errors as well.</p>
  
  <p>XML:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical" 
      android:background="@drawable/order_mode"
      android:descendantFocusability="blocksDescendants"&gt;
      &lt;RelativeLayout 
          android:layout_width="match_parent"
          android:layout_height="wrap_content" 
  
          &gt;           
          &lt;LinearLayout 
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:id="@+id/frame_surface_view"
              &gt;
          &lt;io.vov.vitamio.widget.VideoView
              android:id="@+id/surface_view"
              android:layout_width="match_parent"
              android:layout_height="match_parent" 
              android:layout_gravity="top" 
              /&gt;
          &lt;/LinearLayout&gt;
          &lt;LinearLayout 
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_alignBottom="@+id/frame_surface_view"
              android:layout_alignRight="@+id/frame_surface_view"  
              android:layout_margin="20dp"      
              &gt;
          &lt;ImageButton
              android:id="@+id/btnGift"
              android:layout_width="40dp"
              android:layout_height="40dp"
              android:background="@drawable/gift" 
              /&gt;
          &lt;ImageButton
              android:id="@+id/btnPraise"
              android:layout_width="40dp"
              android:layout_height="40dp"
              android:background="@drawable/praise" 
              android:layout_marginLeft="15dp"
  
              /&gt;      
          &lt;Spinner
              android:id="@+id/spinnerPriaseMessages"
              android:layout_width="0dp"
              android:layout_height="30dp"
              android:textColor="#000000"
              android:gravity="center_horizontal|center_vertical"
              android:textSize="12sp"
              android:layout_below="@+id/indicator"
              android:layout_toRightOf="@+id/txtCount"
              android:background="@drawable/bg_input"
              android:layout_marginLeft="4dp"
              android:layout_marginRight="4dp"
              android:entries="@array/praise_count_array"
              android:prompt="@string/selectPraise"
              android:spinnerMode="dialog" /&gt;                 
          &lt;/LinearLayout&gt;
      &lt;/RelativeLayout&gt;
      &lt;RelativeLayout
          android:id="@+id/webViewRelative"
          android:layout_width="match_parent"
              android:layout_height="wrap_content"&gt;
          &lt;com.mogoweb.chrome.WebView
              android:id="@+id/webView"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:focusable="true" /&gt;    
      &lt;/RelativeLayout&gt; 
      &lt;io.vov.vitamio.widget.CenterLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent" &gt;
      &lt;/io.vov.vitamio.widget.CenterLayout&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>The events</p>
  
  <pre><code>@Override
  public void onBackPressed(){
      System.out.println("Back Pressed");
      if(webView.isFocused()){
          super.onBackPressed();
          finish();   
      }
      System.out.println("BackPressed");
      if(!giftShown){
          mVideoView.stopPlayback();
  
          finish();                   
      }else{
          System.out.println("Hiding Fragment Gift");
          getSupportFragmentManager().popBackStack();
          giftShown=false;
      }           
  
  }    
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) 
  {
      System.out.println("onKeyDown");
      if ((keyCode == KeyEvent.KEYCODE_BACK) ) {
  
          if(webView.isFocused()){
              super.onBackPressed();
              finish();
          }
          System.out.println("BackPressed");
          if(!giftShown){
              mVideoView.stopPlayback();
              finish();
          }else{
              System.out.println("Hiding Fragment Gift");
              getSupportFragmentManager().popBackStack();
              giftShown=false;
          }
      }
      return super.onKeyDown(keyCode, event);
  }
  </code></pre>