title: How can I run java code within phonegap / cordova?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2727763/communication-between-android-java-and-phonegap-javascript">Communication between Android Java and Phonegap Javascript?</a>  </p>
  </blockquote>
  
  
  
  <p>I have some code I would like to run whenever the user presses a button within my Phonegap index.html interface</p>
  
  <p>// toggle airplane mode</p>
  
  <pre><code>  Settings.System.putInt(
    context.getContentResolver(),
    Settings.System.AIRPLANE_MODE_ON, isEnabled ? 0 : 1);
  </code></pre>
  
  <p>// Post an intent to reload</p>
  
  <pre><code>Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
  intent.putExtra("state", !isEnabled);
  sendBroadcast(intent);
  </code></pre>
  
  <p>I would like to launch that code whenever a button is pressed. Maybe make a javascript function somehow that runs java code (if possible), so I can make something like</p>
  
  <pre><code>    &lt;input type="submit" onlick="reconnect();" value="Reconnect to Cell Tower"&gt;
  </code></pre>
  
  <p>I am using Cordova 1.9.0</p>