Android - WebView dies on resume - android

I have Activity with some data displayed in WebView that I load with WebView#loadDataWithBaseURL
Then I have/click menu option that fires android.content.Intent.ACTION_SEND
Choose email from the chooser
Google email comes up (as expected)
Discard email and hit back button
Action with WebView tries to resume
Bang - I get NullPonterException at line 4380 in WebView.java if (mWebViewCore.getSettings().getNeedInitialFocus()) since mWebViewCore is now null
The only place in code where mWebViewCore is nullified is at WebView#destroy - how do I recover from this? Do I need to recreate the browser and load my data all over again, that seems pretty wasteful? I really appreciate good suggestion at this point

Well, I can tell you that I just tested using a WebView with loadDataWithBaseURL(), where the page I loaded had a link. Clicking on the link brings up the Browser application, as expected. BACK button-ing out of the Browser brings back my app with the WebView just fine, no exceptions.
So, either ACTION_SEND/Gmail are somehow special, or there is something more going on with your app.
Can you replicate the problem in a small project that you can post somewhere?

Related

Page dart call in loop without calling it anywhere

I am creating a mobile application in dart allowing the company to place orders directly via their phone, once the order is finished and paid a congrat page is displayed to inform the merchant that it worked, however once back on the application when I click on any input of any page the congrat page is redisplayed and re-debits the customer all this in a loop (4 times), I never call this page in my Ontap or OnClick event and the page is not imported either.
Do you have an idea ?
I thank you !
I have tried different ways of debugging but nothing works, I do not understand where the problem comes from knowing that on

Android 12 - Opening a https intent causes app to restart activity and then launches browser

I'm seeing a strange behaviour only happening on android 12 devices.
In a Fragment of the app we tap to open a link in the browser like this:
Intent(Intent.ACTION_VIEW, Uri.parse(link)) and then startActivity(intent)
The link is to our own website which has the host verified.
What happens then is the MainActivity is destroyed and restarted and afterwards, the browser opens.
The app is based on a single activity with Fragments and has launchMode=singleTask
Devices running other than android 12 just open the browser and when going back the app is at the last Fragment visited - this is the desired behaviour and what I would expect as well.
A note on this is that the app handles deep links correctly. It also has the autoVerify enabled and the setup for the assetLinks.json is correct - the app open automatically when clicking a link.
My lines of thought is that the changes introduced around deep links and autoVerify must be causing this. If we swap the link for https://www.google.com it doesn't destroy the MainActivity and we can visit the website and go back to the app. Any other link with one of our hosts causes that behaviour.
Curious if anyone has experience the same. We are thinking in opening a webview inside to avoid this as a temporal solution but it wouldn't be ideal to do so.

Autofill service not populating user info into a form within a webview in my app

I looked at several issues and was unable to find one that matched mine; apologies ahead of time if I missed it!
I have a native app, a portion of which contains a webview. The webview leads to a page that has a login. When going to the login form android autofill suggestions will pop up and upon selecting them the login process "appears" to initiate however, I'm not actually seeing my onSubmit function firing from the page contained within the webview and ultimately the page returns to the login page as the user is not actually authed. I'm also not seeing the user items populated in the contained webpages state.
Any ideas on why the autofill items are not populating in the form within the webview? Any other things I can try to debug this?
For my particular case, I was actually changing the webview's HTML in the onPause() lifecycle event to ensure the webview stopped hitting our backend; something that was creating incorrect usage stats. This functionality should actually have been placed in the onStop() as it is:
The behavior I actually wanted as I only needed to change the HTML when my app is not visible to the user.
The autofill service triggers onPause() thus making it so the HTML would be changed when the app was still visible and thus, the HTML android was trying to autofill was no longer present.

Android App Lifecycle and Intents

I'm having a bit of an issue with interaction beween my app and other apps on my phone, but I'm starting to think that maybe it's working as designed? Anyway, here's the problem.
My App, call it App A is a photo-manipulation app. So a user goes in, plays around to make changes and then uses the Share button to pass it on (SEND Intent). The photo is sent to another app, chosen from the Share menu, call it App B. This stand-alone app has its own menus, completely different look and feel, etc. The user does his thing in this app for a bit, then hits the home button and goes his way to do something else.
Sometime later, he decides he wants to run my app again. He goes into the launcher, hits the icon for App A (my app), and up pops App B. Very confusing. If he happens to remember that last time he ran App A, he used the share button to get into App B, maybe he'll think to use the back button, to get back into App A. If he doesn't remember, all he knows is that he is trying to use App A, but Android is giving him App B.
(I have one app on my phone that takes over the back button for its own use so you more-or-less get stuck in App B with no way out. Ugh. You hit the icon for App A and always end up in App B)
Is there any solution to this, or is it working as designed? None of my onCreate, OnResume, onStart, etc. methods get called when this is second-open is occurring, so I can't trap it. And realistically, I can see the desire for this behavior when timelines are short - i.e. hit the home button, quickly use some other tool, and then go back to what you were doing. But with a timeline any longer than a minute or two, it gets very confusing.
Anybody else dealing with this problem? Is there a basic Android architectural issue here? Is the SEND intent being mis-used by being accepted by stand-alone apps instead of small utilities?
I think you may use Intent flag 'FLAG_ACTIVITY_NO_HISTORY'. It means starting intent never goes into activity stack.

Android: Browser back button will not fire $getJSON event

I have a test project that uses $getJSON to pull data from web services like Geonames and our own proprietary services. The index page uses two $getJSON calls, and they load fine both when you first load the page or press the refresh. However, if you navigate to another page and then hit the back button to go back to the index page, the page begins reloading and just stops when it hits the $getJSON calls. I've read about Android browser not caching well with the back button in 2.1 (what I'm using)- I'm fine with page reloads as long as it actually completely loads the page.
I've tried this in Firefox and it caches the index page, so there's no re-running of the JSON calls. That's why I'm asking it here in an Android capacity- is it purely the no-caching back button thing that is the problem or is there something I could change about my $getJSON calls?
Here's the page:
http://MPulsemobile.info
My experience is that the Android browser does not report events for the back button like other browsers.
Imagine you have a form containing a text field, and the text field contains, say, 3 characters.
Create a JavaScript alert that will fire on keyup() and begin deleting characters. The alert will not fire until the final key up.

Categories

Resources