title: Set a variable to be seen by all activities using javascript
body: <p>I need to set a variable to be seen by all the activities in the app using javascript loaded in a webview.
  I've tried binding javascript but it's not working.</p>
  
  <pre><code>package xxxx.xxxx;
  
  import android.app.Activity;
  import android.content.Context;
  import android.webkit.JavascriptInterface;
  import android.widget.Toast;
  
  public class WebAppInterface extends Activity {
      Context mContext;
  
      /** Instantiate the interface and set the context */
      WebAppInterface(Context c) {
          mContext = c;
      }
  
      /** Show a toast from the web page */
      @JavascriptInterface
      public void showToast(String toast) {
          // set
          Toast.makeText(mContext, toast, Toast.LENGTH_SHORT).show();
          ((MyApplication) this.getApplication()).setIdUser("foo2");
          // get
      }
  }
  </code></pre>
  
  <p>I'v also tried without "extends Activity" but I get this error: Cannnot resolve method 'getApplication()'</p>
  
  <p>Here it's the JavaScript and HTML code:</p>
  
  <pre><code>&lt;script type="text/JavaScript"&gt;
      function showAndroidToast(toast) {
          Android.showToast(toast);
      }
  
  &lt;/script&gt;
  &lt;input type="button" value="Say hello" onClick="showAndroidToast('Hello Android!')" /&gt;
  </code></pre>
  
  <p>The toast is showed but the global variable is not set.</p>