簡體   English   中英

如何在Android應用上訪問相機onclick?

[英]How to access camera onclick on Android app?

我目前正在使用Visual Studio來處理我的項目,我需要一個允許按下按鈕打開相機的功能。 我有一些來自之前項目的代碼,但它們現在似乎不起作用。 以下是我的代碼。

JS:

function getImage() {
    // Retrieve image file location from specified source
    navigator.camera.getPicture(uploadPhoto,
        function (message) { alert('get picture failed'); },
        { quality: 10, destinationType: navigator.camera.DestinationType.FILE_URI, sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY }
    );
}

HTML:

<form id="buyforme">

<img id="myimg" height="100">
<input type="button" name="selectimg" id="selectimg" onclick="getImage();" value="Take a picture of this item :)">

如果您還需要了解其他信息,請告知我們並告訴我們! 謝謝你們!

要訪問手機攝像頭以獲取androidios photovideo ,您只需使用input[type="file"]如下所示:

獲取照片:

 <input type="file" accept="image/*" capture="camera">

獲取視頻:

<input type="file" name="video" accept="video/*" capture="environment">

用於打開后置攝像頭:

<input type="file" name="image" accept="image/*" capture="environment">

而對於自拍相機(前):

<input type="file" name="image" accept="image/*" capture="user">

資源

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM