Is there a way to give my android app camera access permission with AdvancedWebView?
It is possible with native webview, but the native do not allow file upload through < input type="file" >, so now I have the file upload working, 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);
}
}
The
mWebView.setGeolocationEnabled(true);
line gives the location permission just fine, is there something like that for the video?
Manage to make it work! Once you have your camera capture working in webbrowser, to grant the camera permission:
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" />
Only tested in android 5 so far.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With