Pankaj
Pankaj

Reputation: 861

Android 34 - Webview stopped loading unexpectedly and load once close the activity

We've got a WebView that we're loading under the Application class whenever the app starts. This website is for internal data loading and won't appear to end users. All was well; till then, we upgraded the application to Android SDK 34. While loading the WebView, at some point during the loading, unexpectedly, it stops loading and keeps on the same state till we close the application.

Note that we've got another WebView that loads WebView to display web pages. Is someone having a similar issue? Any clue or solution is appreciated. Thank you

Upvotes: 0

Views: 404

Answers (2)

Martin Zeitler
Martin Zeitler

Reputation: 76679

When you're writing: "for internal data loading and won't appear to end users" ...
this suggests, that you've kind of abusing the WebView for a task it's not meant for.

For loading data, where a WebView isn't required to display data, better use Retrofit.
This also has the advance, that it can properly deal with headers, which JavaScript can't.
It's usually not required to bind to the Activity life-cycle; but this is well possible:
Retrofit and Activity Lifecycle.

The mere problem with WebView is, that what happens inside of it needs to be bridged with callbacks, while when creating a client for an API or web-site, this is within the application itself. This may not be as flexible as a WebView, but it's more solid and provides better control.

Upvotes: 0

Pankaj
Pankaj

Reputation: 861

Found that web didn't stopped loading itself, thought, we were using stopping webview onPause() explicitly in code. May be problem with other people can be different but if someone facing similar issue then do check throughout if we're stopping or pausing web loading? Thanks

Upvotes: 0

Related Questions