title: Resume Android webview when paused by OS/ run JavaScript on app in background?
body: <p>FIrst off I am working on an application that needs to run JavaScript when the app is not in the foreground; the problem appears to be that when the app is put into the background/ the webview is detached from the screen the webview's onPause method is called which per docs does the following:
  "Pauses any extra processing associated with this WebView and its associated DOM, plugins, JavaScript etc."</p>
  
  <p>From what I've found thus far my best bet seems to be using reflection to call the webview's "onResume" method which should undo all these process suspensions. With my current implementation I get an instance of said method but when invoked nothing appears to happen as my subsequent JavaScript call does nothing (mind you this works when I have the application open and in the foreground). </p>
  
  <p>Anyone else see an issue im my code or have a solution to running JavaScript when your app is in the background without fully launching the app?</p>
  
  <p>Push message comes in saying JavaScript needs to be ran so intent is sent to notify service running in background:</p>
  
  <pre><code> Intent intent = new Intent( "some action" );
   intent.putExtra( "xtifyJson", xtifyJSON.toString() );
   context.sendBroadcast( intent );
  </code></pre>
  
  <p>In the onReceive of my Broadcast receiver, which lives in the background service always running:</p>
  
  <pre><code>final String stringArrayExtra = intent.getStringExtra( "xtifyJson" );
   if ( !Text.isNull( stringArrayExtra ) ) {
  
       new Handler( context.getMainLooper() ).post( new Runnable() {
  
            @Override
            public void run() {
               try {
                  Log.d( "Hey Dev Guy", "Message received" );
                  JavaScriptInterface javaScriptInterface = ( (SpecialApplication) getApplicationContext() ).getJavaScriptInterface();
                  relectHiddenMethod( javaScriptInterface.getParentWebView(), "onResume" );
                  javaScriptInterface.getParentWebView().resumeTimers();
                  javaScriptInterface.callBackPushReceived( new JSONObject( stringArrayExtra ) );
  
            }
            catch (Exception e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
            }
         }
      } );
  
   }
  </code></pre>
  
  <p>reflectHiddenMethod reflection method:</p>
  
  <pre><code>private void reflectHiddenMethod( final WebView webview, final String name ) {
  
      if ( webview != null ) {
          try {
              Method method = WebView.class.getMethod( name );
              Object invoke = method.invoke( webview );
          }
          catch (final Exception e) {
              e.printStackTrace();
          }
      }
  }
  </code></pre>