Cordova InAppBrowser opens double window on Android - android

I have developed an app in Cordova 3.6 with latest version of InAppBrowser. Run on Android device (4.1.2 and others) when the user taps a link to open InAppBrowser, occasionally a double window seems to open up. The second of these windows doesn't close.
To check if it was something I had done in my app, I quickly created a default Cordova hello world app and added the standard window.open code with link like this
OPEN WINDOW
and basic testing on the device revealed the same thing was happening - occasionally fast or double tapping made a double window open up, one of which was uncloseable. Either from <300ms double tap, or from double taps where the browser is slow to launch.
This doesn't appear to happen on iOS.
Any help gratefully appreciated.
UPDATE
Part of the problem on my main app was functions declared in wrong place (onpagecreate) being fired multiple times. I put this here in case someone does anything similar...
However on the hello world app the problem still occasionally happens. I tried with and without Fastclick, but Fastclick didn't work properly (possible conflict with jQuery Mobile, arrghh).

your problem is likely caused by using the 'onclick' event to launch the childbrowser.
onclick has a built in 300ms timeout, which can make an app appear laggy and causes some of the issues above.
Use mouseup/mousedown instead, and inside the handler, disable the listener
OPEN WINDOW
function open(url, name) {
// deregister the onclick listener, insuring the callback resolves
window.open(url,name);
// register the listener
}

Related

Navigation 5 'focus' listener not triggered when app is brought back up from background

I am using React Navigation 5, and I am trying to set up a focus listener on a Screen to perform some actions.
The Screen where I need to set up the listener is a Class component that triggers the browser launch, and I want to listen to when the user closes the browser with the "back navigation" and return to the app.
While testing this flow I noticed that the listener is not triggered when returning from the browser, or even when coming up from the background. On the other hand, I could successfully test that when navigating between screens within the app everything works as expected.
Moreover, I set up also the unsubscriber for the focus listener and I can see that it's not called improperly, and the listener still seems alive.
I searched for other issues, questions on SO, read the docs, but I couldn't find a solution. It's also true that I'm a newbie as long as React Native is concerned, but I would expect that the focus listener is triggered also after putting the app to background.
Or is there actually a way to achieve that?
I managed to create a Snack with a sample code (my app is not using Expo CLI, but I saw that the issue is correctly reproduced there too).
It's a very simple StackNavigator with 2 screens. Screen1 is the Class component in which I want to listen for the focus.
by pressing the "GO TO BROWSER" button, the Google website is opened, but navigating back to the app no logs appear informing that the focus is on;
going to background and getting the app back up no logs appear for the focus;
by pressing the "GO TO SCREEN 2" button, the second screen is opened, and upon back navigation, the focus test log informs us that the focus is now on.
My software versions:
iOS and Android 12.4.7 and API 29&24
#react-navigation/native 5.5.1
#react-navigation/stack 5.5.1
react-native-gesture-handler 1.6.1
react-native-safe-area-context 3.0.5
react-native-screens 2.8.0
react-native 0.62.2
node 12.17.0
npm 6.14.6

Opening Nativescript app from notification does not alway go to last view

I'm having an intermittent problem in which opening my Nativescript based app from a notification does not always take me to the last view the app was on when I minimized it. I'm currently experiencing this on Android 5.1.1.
I know that the Resume event is called when ever the app re-opens and I can put some logic in there to force a certain view to load but oddly it's not always a common problem. When opening the app from a notification, the resume event is hit, and then it just defaults to the start screen of my app. This is not what I want. Is this expected behavior? It doesn't seem like it is since it's intermittent but seems to be happening more often now.
Note: I'm using the Nativescript push plugin to handle client side notifications. I'm also still using NS 2.2.1 since there seemed to be some issues in 2.3 and #next

Cordova battery status event only fires on first page

I have written a small app in Cordova with the battery plugin (tried versions 0.2.11 to 0.2.13-dev). The html contains a href to a second page. The deviceready event is fired on the first and on the second page and the battery status eventlistener is added on both pages. But on the second page the battery status event is not fired anymore, when i go back to the first page, it is not fired anymore, too.
I tried on Android 4.1 and Android 4.4 devices.
It seems that the battery status event fires only on the initial page.
Does anyone have experienced the same? Is there eventually a solution or workaround for this?
Many thanks.
According to documentation http://docs.phonegap.com/en/edge/cordova_events_events.md.html#deviceready
I expect this event is only fired once the application is started - meaning the Cordova Javascript parts are loaded and in cache. I expect the Cordova Javascript from cache is used even when loading a second html page.
You may want to use the Javascript window.onload = function ... to execute something when the page has been loaded.

How to catch back and home button in jQuery Mobile + PhoneGap

I have tried the majority of the solutions posted both here and on other sites. I still can't catch the back button on my PhoneGap + jQuery Mobile android app. Let's start with the basic one:
document.addEventListener("backbutton", backKeyDown, true);
function backKeyDown() {
alert('back button pressed');
}
That doesn't seem to be firing at all.
Another thing I want to do is catch when the home button is pressed. I want to make it so that the app gets killed when I press the home button, mainly for security purposes.
Can anybody help me with my above dilemma?
I'm running into the same issue. I haven't fully solved it yet, but the problem seems to be that calls to the app plugin, including the call to enable button events, aren't running.
I was able to get the backbutton event firing by enabling the native part of the event binding in the java code:
super.loadUrl("file:///android_asset/www/loading.html", 20000);
appView.bindButton(true);
Update:
I found the actual cause of the problem - a bug in the development version of cordova that is now fixed.
Usually updating cordova is the first thing I try, but a simple pull didn't work because the repo is now http://github.com/apache/cordova-android - the old incubator-cordova-android still exists, but is not being updated and contains a version of the code from before this bug was fixed.

Phonegap + Sencha touch 2 + Android first ajax request opens the browser

I have an Sencha Touch 2 application and I'm using PhoneGap (Cordova) to get it to work as an native application.
I got plenty of Ext.Ajax requests in my application and they work fine on iOS (with XCode). But when I launch the application to my Android device thru Eclipse the first executed Ext.Ajax request seems to start and open the ordinary browser with a blank page open. The request still runs and works inside the application at the same time.
The upcoming requests do not do this, and I can close the ordinary browser, go back and run the same request that opened the browser the first time and it will not do it again, until I re-launch my application.
I've tried to search for a solution for this issue but I have not found anything helpful yet, does any one got any ideas on how to solve this?

Categories

Resources