Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opening WebView in background

This is the first time I ask something, so if there is something wrong just tell me and I´ll try to fix it ASAP.

We have a customer that wants us to login in their servers with a native Android app, but without giving us a custom way to do this. They want us to use the current website they have to log and, after authentication takes place, retrieve within the browser a XML which contains the data we need. After that, use the data in the native app. All of this with the user not knowing/seeing that a browser is being used. A total mess IMHO.

Of course, I have never tried this approach in the past and my first tests make me feel like this is impossible (or extremely difficult) to achieve. Whenever I try to load the URL in a hidden WebView the default browser pops up showing the website.

My main question is, is it possible to load a webview and work with it (invoke javascript, etc...) in the background?

Thank you.

like image 552
Luis Ollero Avatar asked Aug 22 '11 10:08

Luis Ollero


People also ask

How will you load URL in WebView in background while splash screen is showing?

You can do it without AsyncTask and you can hide the splash screen when the page loaded without a timer. WebViewClient class has a method onPageFinished() which will be called once the page has been loaded. You can make use of it. In you project folder, place your splash screen images with name 'splash_screen.

How can I make WebView keep a video or audio playing in the background?

Solution. After searching a lot, I found this thread. I did something similar: Just extend WebView and override onWindowVisibilityChanged . This way, the audio continues to play if the screen is locked or another app is opened.

Is Android WebView deprecated?

Beginning October 5, 2021, Facebook Login will no longer support using Android embedded browsers (WebViews) for logging in users.

What is WebView rendering?

If you want to deliver a web application (or just a web page) as a part of a client application, you can do it using WebView . The WebView class is an extension of Android's View class that allows you to display web pages as a part of your activity layout.


1 Answers

You could set the WebView to hidden by default with the attribute android:visibility="gone", interact with it at runtime then when you need to show it to the user after you've loaded data, just call setVisibility(View.VISIBLE)

Hope this helps!

like image 157
AlexPriceAP Avatar answered Oct 17 '22 01:10

AlexPriceAP