android - How to access the camera from within a Webview? -
in android app, trying load webpage (that must access camera) on webview
. on laptop, when load webpage, access camera.
everything else on html
page shown.
here permission putting in manifest.xml
<uses-permission android:name="android.permission.camera" /> <uses-permission android:name="android.webkit.permissionrequest" /> <uses-permission android:name="android.permission.access_network_state" /> <uses-permission android:name="android.permission.access_coarse_location" /> <uses-permission android:name="android.permission.access_fine_location" /> <uses-permission android:name="android.permission.internet" />
i setting sdk follow:
<uses-sdk android:minsdkversion="18" android:targetsdkversion="21" />
here webview setting:
private void setmywebviewsettings(websettings mywebviewsettings){ mywebviewsettings.setallowfileaccessfromfileurls(true); mywebviewsettings.setallowuniversalaccessfromfileurls(true); mywebviewsettings.setjavascriptcanopenwindowsautomatically(true); mywebviewsettings.setjavascriptenabled(true); mywebviewsettings.setdomstorageenabled(true); mywebviewsettings.setjavascriptcanopenwindowsautomatically(true); mywebviewsettings.setbuiltinzoomcontrols(true); mywebviewsettings.setallowfileaccess(true); mywebviewsettings.setsupportzoom(true); }
if access camera app directly (using normal activity), why can't open within webview
?!
if i'm not wrong, want open device camera , upload newly captured photo in webview without opening other application need write_external_storage
permission , methods handle file requests , create new files camera , write device storage.
i hope helps, found open source (android smart webview) can setup things you.
you need openfilechooser()
, onshowfilechooser()
methods understand how handle file requests webview input , activate phone camera capture , create new image without opening other apps.
Comments
Post a Comment