title: Android Dolphin browser plugin development issue
body: <p>I am developing an add on for Dolphin browser for my personal purpose. The feature of the app is to read the Textbox in the webpage and replace it with the url when i click on the sign in button in the webpage.</p>
  
  <p>I have tried running the java script in the Iwebview of the browser's tab using the following code.</p>
  
  <pre><code>package com.dolphin.rpplugin;
  
  import java.io.BufferedReader;
  import java.io.InputStream;
  import java.io.InputStreamReader;
  import java.lang.annotation.Annotation;
  
  import android.os.Bundle;
  import android.os.Handler;
  import android.os.RemoteException;
  import android.annotation.SuppressLint;
  import android.app.Activity;
  import android.content.Context;
  import android.content.res.AssetManager;
  import android.graphics.BitmapFactory;
  import android.util.Log;
  import android.view.Menu;
  import android.webkit.ConsoleMessage;
  import android.webkit.JavascriptInterface;
  import android.webkit.WebView;
  import android.widget.Toast;
  import com.dolphin.browser.addons.*;
  
  @SuppressLint("SetJavaScriptEnabled")
  public class MainActivity extends AddonService {
      private static String TAG = "MainActivity";
      final Handler myHandler = new Handler();
      String jscontent = "";
      IWebView webView ;
  
  @Override
  protected void onBrowserConnected(Browser browser) {
      Log.i(TAG, "Browser Started");
      try {
          browser.addonBarAction.setIcon(BitmapFactory.decodeResource(
                  getResources(), R.drawable.ic_launcher));
          browser.addonBarAction.setTitle("RP Plugin");
          //Web view reading
          ITab tab = browser.tabs.getCurrent();
          if (null == tab) {
              return;
          }
          webView = tab.getWebView();
          if (null == webView) {
              return;
          }
          webView.getWebSettings().setJavaScriptEnabled(true);
          webView.getWebSettings().setSaveFormData(true);
          webView.getWebSettings().setSavePassword(true);
          //webView.
  
          browser.addonBarAction.setOnClickListener(new OnClickListener() {
  
              @Override
              public void onClick(Browser browser) {
                  readURL(webView);
              }
          });
          browser.addonBarAction.show();
      } catch (Exception e) {
          e.printStackTrace();
      }
  }
  
  @JavascriptInterface
  private void readURL(IWebView webView) {
      try {
          // Get current web page
  
          //browser.
  
          String url = webView.getUrl();
          if (url.contains("http://10.1.225.20:8080/Facebook")
                  || url.contains("http://10.1.225.20:8080/Amazon")) {
              excecuteJavaScript();
              /*WebViews webview2 = browser.webViews;
              IWebView webview3 = browser.tabs.getCurrent().getWebView();
              webview3.loadUrl("javascript:(" + jscontent + ")()");*/
          }
      } catch (Exception e) {
          e.printStackTrace();
      }
  }
  
  public void excecuteJavaScript() throws RemoteException {
      Log.i(TAG, "JavaScript Enabling");
  
      // reading the bootstrap java script file from asset folder.
      try {
          AssetManager am = getAssets();
          InputStream is = am.open("replace.js");
          InputStreamReader isr = new InputStreamReader(is);
          BufferedReader br = new BufferedReader(isr);
  
          String line;
          while ((line = br.readLine()) != null) {
              jscontent += line;
          }
          is.close();
      } catch (Exception e) {
      }
  
      webView.loadUrl("javascript:(" + jscontent + ")()");
  }
  
  @Override
  protected void onBrowserDisconnected(Browser arg0) {
      Toast.makeText(MainActivity.this, "Browser Connected",
              Toast.LENGTH_LONG).show();
  }
  </code></pre>
  
  <p>}</p>
  
  <p>this is my replace.js file</p>
  
  <pre><code>function replaceProfile() {
  alert("Heai");
      var elemArray = document.getElementsByName("openid");
      alert("Hello! "+elemArray + " length:"+elemArray.length);
      if(elemArray.value == "john"){
          elemArray.value = "http://google.com/johnsmith";
      }   
  }
  </code></pre>
  
  <p>This way i have couple of issues:
  1) the java script is not able to read the element by name Openid and content in that text box.
  2) webview.loadUrl() is not working for the second time when i click on the plugin.</p>
  
  <p>Could you suggest me how to implement that?</p>