Android Studio access webcam via WebView - android

I'm trying to access and display a webcam interface in my application.
Currently I'm trying to do that using a WebView (still no success), but open to other suggestions.
When I go to "http://192.168.43.74:81" (the ip of the camera) on my phone's browser I get a popup asking me to insert a username and a password, I do that and log the camera successfully.
This is how I try to do that using a WebView:
WebView camera = (WebView) findViewById(R.id.camera);
camera.getSettings().setJavaScriptEnabled(true);
camera.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
camera.loadUrl(CAMERA_URL);
camera.setWebViewClient(new WebViewClient());
When I set CAMERA_URL to google's url for example, I'm able to access google and browse the internet normally, using the webview. When I set CAMERA_URL to the webcam's IP, I get a blank page on my webview, and the following message:
Access Error: Unauthorized
Access to this document requires a User ID
This is the same message I get when I try to log in via my browser, but hit cancel instead of trying to log in. I assume I'm doing something wrong, and would appreciate some help:
How do I make it work?
Is there a better way to go about it than a WebView?
and finally, though a somewhat different question, is there a way to automatically make the login instead of having the user type the username/password every time?
I apologize if this question is trivial, or has been asked before. I was unable to find a solution by searching. Thank you!

Related

Android WebView ERR_TOO_MANY_REDIRECTS

I am trying to allow user to login into our application through a WebView, but when trying to login, I get an error saying ERR_TOO_MANY_REDIRECTS. The login protocol consists of 5 redirects, but we have no control over it.
It works in a web browser, but Anroid WebView starts thinking we are in a redirect loop and cancels the whole thing. Up until API 8 there was a function onTooManyRedirects(WebView view, Message cancelMsg, Message continueMsg), which allowed you to continue, but is now not used anymore.
What can I do to get around this problem?
In my code I have the following line:
webView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
Just deleting this line solve the issue.

Android WebView and Laravel login error

I have a Laravel application with login.
It all works fine in a browser, but if I use Android WebView, and try to login, I get an error
Trying to get property of non-object
This is because, when I try and get the user with Auth::user(); it returns null.
I am logging my user in using auth()->login($user) in a function. If I dd($user) at this step, it does get the correct user - but then I redirect into /dashboard which then fires a function, where the first thing it does is to try and get the user.
Its at this point it breaks.
This all works in a browser - also in an android browser. But not in Webview.
Can this have anything to do with the session cookie or something? Is it possible to try and dd() the session cookie to see if it exists?
And if it doesn't, how come this isn't setting in Android Webview?
I have tried using CookieManager.getInstance().setAcceptCookie(true); but this isn't helping, and should also be defined by default.
All help appreciated

Android - WebView not saving input forms

I'm using a simple webView client in my android application, but, when the user log in, close the app and open app again the input forms not save the user information like webbrowser.
How i solve it?
I need when the user enter the 'username' the app save this like a webbrowser, if possible save the password too :)
Thank in advance.
Have you tried following the tutorial on the Android Developer site from Google?. I think that this is what you are looking forward to achieve....
"" Building Apps with Contacts & Sign-In ""
https://developer.android.com/training/building-userinfo.html

Paypal site is not redirecting after successful payment in mobile browser

Paypal site is redirecting after successful payment in desktop browser
but not in mobile browser
When I am making payment from mobile browser I am getting the following error
[INFO: CONSOLE(2)] "TypeError: Cannot read property 'removeClass' of
null", source:
https://www.sandbox.paypal.com/WEBSCR-640-20160131-1/Mobile/js/min/checkout.js
(2)
well, First-off you should elaborate your question with details and a proper link. I wont open anything that doesn't check through. Now coming back to your question. And, I'm basing my answer with whatever little information you provided, this question really isn't worth without proper information.Refer this.
Just a few checks along the way, are you using similar browser on both devices. If not, mention that also, mention what browser in particular that'll be required too. Sometimes your security settings get in the way, check your sec settings on the respected device. Most obvious reason could be failure to complete packet data request in-time, your device took too long to respond to the request.You know why this happens right,see this :). Hence the service was denied. Simple!.

oAuth support in a WebView

So I've created a simple WebView application that wraps an already existing mobile friendly site and displays it on the device. I've enabled javascript, supported screen orientation changes, etc...
I've run into an issue with the oAuth support though. Accessing the site from the chrome browser on the device, everything runs fine.
If I try to access the site from the app/WebView, it will push me over to the oAuth screen, let me input credentials and everything, but the moment it tries to push me back to the website and log me in, I get this:
Failed to recognize URL query:
https://exittix.com/frontend/login/redirect.html#access_token=******************************&expires_in=********&state=****client_id=******************network*****facebook*****display***popup****callback****_hellojs_agj27sx5****state****oauth_proxy***https***auth-server.herokuapp.com%2Fproxy***scope***basic_profile***email***basic***oauth***version***auth***https***facebook.com%2Foauth***
The * is used to protect data.
So, any ideas why oAuth isn't working inside a JS enabled webview but works fine in the mobile chrome browser for android?
Thanks in advance for your help!
EDIT:
Ok, so I've tracked the error I'm getting back to redirect.html.
This page calls some javascript. If the javascript fails to redirect, then it displays that error I have above instead.
The javascript being called to handle the oAuth is Andrew Dodson's hello.js script.
You can see it HERE.
I've concluded that the second half of the error's url is indeed the unhandled JSON.
Here's what the returned data looks like after I've decoded it from the URL encoded characters:
{"client_id":"************.apps.googleusercontent.com","network":"google","display":"popup","callback":"_hellojs_********","state":"","oauth_proxy":"https://auth-server.herokuapp.com/proxy","scope":["https://www.googleapis.com/auth/userinfo.profile","https://www.googleapis.com/auth/userinfo.email","basic"],"oauth":{"version":2,"auth":"https://accounts.google.com/o/oauth2/auth"}}&access_token=***.*.*****_*********************************************************&token_type=Bearer&expires_in=3600
Any ideas why this isn't getting handled properly in the WebView?

Categories

Resources