-1

I am trying to launch to android camera with an onClickListener and take a picture which saves to a specific folder onto the sdcard and then displays the captured image inside a webview. heres my code so far.

private static final int CAMERA_REQUEST = 1888;
WebView WV;
Button capture;
Uri mCapturedImageURI;






@Override
public void onCreate(Bundle savedInstanceState) {



    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    this.WV =(WebView) this.findViewById(R.id.webView1);

    this.capture =(Button) findViewById(R.id.button1);


    capture.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {


             String fileName = "temp.jpg";  
                ContentValues values = new ContentValues();  
                values.put(MediaStore.Images.Media.TITLE, fileName);

                mCapturedImageURI = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);  


            Intent cameraIntent = new Intent (MediaStore.ACTION_IMAGE_CAPTURE);
             cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, 
                     Uri.fromFile(new File( "sdcard/image")));  



             startActivityForResult(cameraIntent, CAMERA_REQUEST);


        }
    });

}
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {  

     super.onActivityResult( requestCode, resultCode,  data);

     if (requestCode == CAMERA_REQUEST) {

         setContentView(R.id.webView1);
         WV.getSettings().setAllowFileAccess(true);
         WV.getSettings().setJavaScriptEnabled(true);
         WV.getSettings().setBuiltInZoomControls(true);
         String html = ("<html>" +
                "<head>" +
                "</head>" +
                "<body>" +
                "<img src=\"sdcard/temp.jpg\" alt=\"alternativo\" />" +
                "</body>" +
                "</html>"
                );
         WV.loadDataWithBaseURL("", html, "text/html", "utf-8", "");


     }

    }     


}

1 Answers1

0

You can only pass primitive data types with the putExtra() (String, int, float, etc).

Here is the doc that will help you with that:

http://developer.android.com/reference/android/content/Intent.html

If you want to pass other data, use the Parcelable interface

BlackHatSamurai
  • 23,275
  • 22
  • 95
  • 156