Chrome Inspector shows Android Webview in AVD but not on actual device - android-webview

I have an Android app with a WebView which shows a simple web page. If I run the app in Android Studio's AVD (virtual device), I can inspect the WebView in Chrome Inspector. However, if I run the app on my device, I can't see the WebView. I can see Facebook (com.facebook.katana) and I can see all my Chrome tabs, but the WebView is missing.
In the past, I have been able to see the WebView on my device as well but this stopped working a few weeks ago. (Developer tools are active and USB debugging is active)
Can anyone help me figure out why the WebView is not inspectable in Chrome Inspector?

Make sure you are calling WebView.setWebContentsDebuggingEnabled(true); in your application (see https://developer.chrome.com/devtools/docs/remote-debugging#configure-webview for full info). AVD runs a "debug" Android image, where debugging of WebViews is enabled by default. On regular (so called "user") images you need to have it enabled by your app.
Another point to consider is that you need to create at least one WebView instance in order to see your app listed in chrome://inspect.

For me...the DeVTools window is blank...ive tried this for both our app and viewing Chrome through the devive

Related

Close browser window and open PWA once PWA installed

I have Chrome installing my PWA on Android - once it's installed I'd like to automatically close the browser window it was installed from, and open the PWA (so the user doesn't continue in the browser window, thinking they're using the PWA) - is this possible?
i was looking for a similar solution and have not yet found a way to do that. I try to describe my findings so far:
CLOSING THE BROWSER WINDOW:
as described in this answer window.close() can only be called on windows/tabs that the script opened itself. Some possible workarounds are being discussed there.
OPENING THE PWA RIGHT AFTER INSTALLATION:
Google describes in their WebApk Fundamentals Article it as follows:
When a Progressive Web App is installed on Android, it will register a set of intent filters for all URLs within the scope of the app. When a user clicks on a link that is within the scope of the app, the app will be opened, rather than opening within a browser tab.
I was hoping that would work also right after the installation/Adding to homescreen from the still open browser window.
Based on testing with two Android devices it seems as if at the moment the user has to manually open the PWA from the homescreen once for chrome/android to interpret the scope of the web apps manifest.json as intend to open the page in standalone.
This is sad for even iOS seems to handle that different.
Maybe I am overlooking something in the Google Article? I also do not fully understand androids intent API - so maybe there is some way to still achieve that (?)
Based from this blog post:
When the PWA is installed, it will appear in the home screen, in the
app launcher, in Settings and as any other first-class citizen app in
the OS, including information on battery and space used in the system.
There's a tracking event when the user opens the app from the home screen. That means the user has clicked the app's icon or, on Android with WebAPK support, also clicked on a link pointing to the PWA scope and need to close the browser.
start_url: '/?utm_source=standalone&utm_medium=pwa'
Also, the following script leaves us a boolean stating if the user is currently in a browser (true) or a standalone app mode (false)
var isPWAinBrowser = true;
// replace standalone with fullscreen or minimal-ui according to your manifest
if (matchMedia('(display-mode: standalone)').matches) {
// Android and iOS 11.3+
isPWAinBrowser = false;
} else if ('standalone' in navigator) {
// useful for iOS < 11.3
isPWAinBrowser = !navigator.standalone;
}
I had this problem on Android with Chrome. The change that made the difference is adding "target='_blank'" to the link. It looks like:
window.addEventListener('appinstalled', function(event){
setTimeout(function(){
presentToUser("<a href='https://myhostname.com' target='_blank'>Go to App</a>")
}, 10000)}
});
The ten second timeout is to give Android the time to set up the App on the home page.
I had made that adjustment earlier; possibly I can remove it?
But setting the target was what made this work.
The App opens over the top of Chrome, obscuring it.
So closing the browser is not immediately required but is recommended.
In the new versions of chrome, after installation in android it associate all the links in the "scope" to the PWA application, if you try to open a link in your chrome browser it open directly in the application.
hope that will answer your question

What browser opens a PWA when it is launched from home screen app icon

I am examining PWA and Web Components technologies recently. As far as I have learned now Web Components is a new suit of tech,
Custom Elements, Shadow DOM, HTML Templates and HTML imports. Together with those Web Components enabling techs Web App Manifest, Service Workers, and certain performance improvement techniques used to make what is called as Progressive Web Applications.
What I wonder is when one "Adds to Home Screen" an application in a certain web browser what is the browser that opens it when it is launched from its home screen icon? Is it the browser it has been added to home screen from, or it is the default browser of the system no matter which browser it has been added to home screen from, or it is just a generic web view available on the host operating system at the moment like the one used in native web applications?
Lastly, is it possible for a developer coding her/his app to choose one?
Currently, for me, these combinations open a new "Standalone" window
I believe Android/Chrome is the only one that installs a WebApk
All the others are just shortcuts to open your website in that browser without the normal browser navigation items
I know of no options for the developer for how the shortcut opens your PWA
Android 8.10 - Chrome 67
Android 8.10 - Chrome (beta) 68
Android 8.10 - Edge 42
Android 8.10 - Opera 43
iOS 11.4 (simulator) - Safari
As test I created app shortcut of site https://pwa.rocks from browser:
Brave
Firefox
Chrome
and found that there were 3 different shortcut created for each of the browser. Launching each shortcut resulted in opening the respective browser that created it.
I believe there is no way of changing the default browser to launch the app by coding something in the app. I could not find a way of doing that, if someone knows how to do it, I will be interested to know about it
Here is similar question: What browser will PWA (Progressive Web App) use after adding to home screen?

B4A - webview using chrome browser

In the WebView that is based on default browser of android my website isn't loading correctly, How can I load it using chrome at least in the case that chrome is installed?
Note that I don't want execute chrome browser I want to embed it inside of the application layout. Any ideas?
I think what you are asking is not possible. The default browser used within the webview is defined within the Android OS so your only option if you wanted to use Chrome is via an intent which would open it externally

Can I debug Desktop Safari with Chrome Devtools?

Safari's Web Inspector is absolutely awful, and it keeps crashing on me. One of my colleagues suggested using Chrome Devtools to inspect Safari pages via Remote Debugging. I haven't found anything on Google for how to do such a thing--is that possible?
Safari and Chrome use different debugging protocols (initially these were very similar, but over time they grew into separate things). Thankfully, there is a Google project that does the translation between these protocols - iOS WebKit Debug Proxy. It doesn't mention desktop Safari though.

Iphone4 "add to home screen" instant startup

How do you make a web app start up instantly - is it possible to make as fast as a native app that is already loaded?
I have developed a HTML5 web app that runs nicely on Iphone 4 with a splashscreen. But now I'm looking into performance:
I use a manifest file to ensure that all files are loaded from the local storage. I have checked both in chrome and mobile safari, that the files are stored correctly locally. Now performance it quite different depending on how I access my web app:
~4s When I load the web app in browser (not from a home screen icon).
~6s When I load from an "add to homescreen" icon
When I load in chrome browser it takes 234ms to load and render the whole page. I seems like the lack of speed is due to the rendering being pretty slow.
Any performance suggestions are very welcome.
I know from experience that a MacOSX device the Chrome App all of its previous versions/updates leaves in its App. This maybe also apply to ios, since it's is a stripped version of the MacOSX sysem.
It might help to delete the Chrome App from your iPhone and re-install it from the App store.
This way you be sure you have a clean copy op Chrome on the iPhone whithout all the previous Chrome versions.
I hope this helps.