Accessing video using android AdvancedWebView
Is there a way to grant camera access permission for Android apps with AdvancedWebView ?
It is possible with native web view, but native does not allow file uploads via <input type = "file">, so now file upload works for me, but no camera.
Main code:
public class MainActivity extends ActionBarActivity implements AdvancedWebView.Listener {
private AdvancedWebView mWebView;
@Override
protected void onCreate(Bundle savedInstanceState) {
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mWebView = (AdvancedWebView) findViewById(R.id.webview);
mWebView.setListener(this, this);
mWebView.setGeolocationEnabled(true);
mWebView.loadUrl(url);
}
}
mWebView.setGeolocationEnabled(true);
the line gives the post permission just fine, is there something similar for the video?
+3
source to share
1 answer
Manage your work! If you have a camera capture running in a web browser to give the camera resolution:
public void iniciaWebView(){
mWebView = (AdvancedWebView) findViewById(R.id.webview);
mWebView.setListener(this, this);
mWebView.setGeolocationEnabled(true);
mWebView.addHttpHeader("X-Requested-With", appNomeLogs);
mWebView.setWebChromeClient(new WebChromeClient() {
@Override
public void onPermissionRequest(final PermissionRequest request) {
Log.i(appNomeLogs, "|> onPermissionRequest");
MainActivity.this.runOnUiThread(new Runnable(){
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public void run() {
Log.i(appNomeLogs, "|> onPermissionRequest run");
request.grant(request.getResources());
}// run
});// MainActivity
}// onPermissionRequest
});// setWebChromeClient
mWebView.loadUrl(url);
}// iniciaWebView
manifest:
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.CAPTURE_VIDEO_OUTPUT" />
Tested on Android 5 only.
+4
source to share