If i understand your question correctly
You want to open the android device camera on click of a button in the webpage(html)?
On the basis of that assumption,
You need to do the following
Use a JavascriptInterface
public class WebVCamBridgeInterface {
/**
* Javacript function to start native camera
*/
@JavascriptInterface
public void takePicture() {
captureImage();
}
/**
* Javascript function to start the GalleryActivity for user to choose the image to be uploaded
*/
@JavascriptInterface
public void showPictures() {
Intent intent = new Intent(LandingActivity.this, GalleryActivity.class);
startActivityForResult(intent, Constants.REQ_GALLERY);
}
}
add JSinterface to your webview
webView.addJavascriptInterface(new WebVCamBridgeInterface (), "AndroidDevice");
Have the following JS in your html/web page
<script>
function takePicture() {
if(typeof AndroidDevice !== "undefined"){
AndroidDevice.takePicture();
}
}
function showPictures() {
if(typeof AndroidDevice !== "undefined"){
AndroidDevice.showPictures();
}
}
function imageData(data){
document.getElementById('displayImage').setAttribute( 'src', 'data:image/png;base64,'+data );
if(typeof AndroidDevice !== "undefined"){
}
}
</script>
Im providing the link to a sample project with video of a demo ,have a look.
https://drive.google.com/drive/folders/0BwRMp8dK9LMLeEo5cTlXVE9ZUW8?resourcekey=0-6dEjytPymBZvebmmyy9ymQ&usp=sharing
You can also refer these tutorials
cheers!.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…