title: android native and javascript communication in browsing a file from device
body: <p>I have opened html page in webview. Now on click of any button in the webview, I want user to pick an image from gallery and show that image in webview.</p>
  
  <p>Code in onCreate() method:</p>
  
  <pre><code>       myBrowser = (WebView)findViewById(R.id.webView1);
  
         final MyJavaScriptInterface myJavaScriptInterface
          = new MyJavaScriptInterface(this);
         myBrowser.addJavascriptInterface(myJavaScriptInterface, "AndroidFunction");
  
         myBrowser.getSettings().setJavaScriptEnabled(true); 
         myBrowser.loadUrl("file:///android_asset/mypage.html");
  </code></pre>
  
  <p>Added javascriptInterface:</p>
  
  <pre><code>   public class MyJavaScriptInterface {
        Context mContext;
  
           MyJavaScriptInterface(Context c) {
               mContext = c;
           }
  
  
           public void pickImageFromGallery()
          {
              Intent i = new Intent(
                       Intent.ACTION_PICK,
                       android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
  
               startActivityForResult(i, RESULT_LOAD_IMAGE);
          }
  
       }
  </code></pre>
  
  <p>onActivityResult() method:</p>
  
  <pre><code>       @Override
      protected void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);
  
          if (requestCode == RESULT_LOAD_IMAGE &amp;&amp; resultCode == RESULT_OK &amp;&amp; null != data) {
              Uri selectedImage = data.getData();
              String[] filePathColumn = { MediaStore.Images.Media.DATA };
  
              Cursor cursor = getContentResolver().query(selectedImage,
                      filePathColumn, null, null, null);
              cursor.moveToFirst();
  
              int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
              String picturePath = cursor.getString(columnIndex);
              cursor.close();
  
              BitmapFactory.Options o2 = new BitmapFactory.Options();
              o2.inSampleSize = 4;
              Bitmap image = BitmapFactory.decodeFile(picturePath, o2);
  
  
          }
  
  
      }
  </code></pre>
  
  <p>Now whenever I will click on the button in webview, it open the gallery and let the user to select an image from the gallery. 
  But how can I send that image path again to the javascript, so that It can show that image in webview?</p>