I have experienced such a weird behaviour from titanium project using alloy that runs on android. I created a new window and then link it to another. like in android when you click button on activity 1 it refer to activity 2. when i click back button it back to activity1 (in android). But in alloy, when i pressed back, no matter on windows i'm in, it always back to home. Not back to the first window (or before it). How can i do such a thing in alloy to get the back button result same like in android.
activity1>>activity2>>activity3>>activity4
when you pressed back button it should back to activity3, but in alloy its just back to home.
If someone know how to achieve that (same like in android). Or simple example would be better.
NOTE: it solved using classic mode. i'm confused using the mvc one.
Write this piece of code when the window loads:
win.addEventListener('android:back', function(e) {
console.log("Pressing Back Will Not Close The Activity/Window");
win.close();
});
Related
I am working on a PWA and I have a page with a full screen modal in it, which pops up upon a button click to perform a specific action.
On the modal I have a close button tied to a function which works fine in closing the modal. However I noticed that on most native apps, when a modal is active clicking the (android) back button in a UI like mine closes the modal instead of going to the previous view.
My concern is if it were possible to listen to the android back button being clicked, prevent the default action and call another action. Or if there's anyway else around this!
I've made researches but all I can see is handling the browser back button, which in my case does not work. Tested on samsung A30,S10,A50.
From the Suggested question which I had gone through, There's no answer concerning how to handle the back button, Only on how to intercept it. And none of those answers my question.
Kindly note, PWA is already installed, hence in standalone mode
There is no way to handle the back button of Android in the PWA environment.
It is a system button which "clicks" the history.back() of an open browser. If there is no back-history it closes the browser.
But it doesn't know anything about this special button. There would be the need for something like the keypress-events. But there is no standard and so no implementation in the browsers.
The only way to handle this stuff in your app, is to manage the history.state in your app.
Push a new state with opening the modal. And close the modal in the popstate-event.
https://developer.mozilla.org/en-US/docs/Web/API/History_API/Working_with_the_History_API
I am making a hybrid app. I am using xamarin for android, pretty much the same as android. I have already figured out how to hook the phone's back button press. When pressed I want my app code to either mimic or call a javascript function that is part of the webpage that the webview is displaying. It is my web page, so I know the code that the webview is rendering. To be specific, I want to call a jquery slideToggle function on a page element when the phone's back button is pressed. Can that be done, and if so what would be the best approach? I'm hoping that someone here has had to do something just like this in the past. Thanks.
I don't think webview supports JQuery, unless maybe you reference it.
The Xamarin android way of doing it is:
webView.addJavascriptInterface(new JsObject(), "injectedObject");
webView.loadData("", "text/html", null);
webView.loadUrl("javascript:alert(injectedObject.toString())");
Source : Android.Webkit.WebView.AddJavascriptInterface Method
Also make sure you have enabled Javascript,
web_view.Settings.JavaScriptEnabled = true;
You can show or hide the element by finiding it by id (document.FindElementById). Then you can set its display to block or none. Thus you can do it purely in Javascript.
Add on :
There are couple of problems with your method. To name a few -
on pressing of back button user expects a particular behavior and it should not be altered. This would not give a rich user experience.
if you are override ing the back button press then what about the navigation bar menu click.
JavaScript way of doing can cause security issues.
I am developing a SharePoint App that basically launches a form in a Windows 8 application once the action is clicked. This is working perfectly fine. However, once you select this action, you are redirected to a page that basically holds some parameters to launch the app. This page throws a window that asks the user if it's okay to launch the app:
How can I detect if this has been launched or not? Ultimately I'd like to detect if the user hits 'Allow' or 'Cancel' but either scenario will work. I am trying to redirect a user to the parent page once this window has launched (hopefully when the user clicks 'Allow'
Is this possible? I found a helpful thread here: http://support.smartbear.com/viewarticle/55730/
However, this thread is very useful but doesn't give me the answer I need. I've tried using jQuerys .blur and this works(ish). It isn't giving me a consistent response but looks like it's a step in the right direction (if I can't detect the window that launches). I've also tried the following code by using .hover but am receiving inconsistent results.
$(window).hover(function (event) {
if (event.fromElement) {
console.log("inactive");
window.location.href = "http://google.com";
}
else {
console.log("active");
}
});
At the highest level possible, I'm trying to redirect the user once the app is launched.
Thanks in advance for any helpful input.
This seems like a simple fix, but I can't find any information!
Our mobile site in Safari has been sporatically displaying a dialog saying 'Open this page in "App Store"?' with a cancel and open button, both of which dismiss the dialog but don't do anything beyond that. This dialog doesn't come up all the time, but we have nothing explicitly calling this dialog and want this gone.
We do have a smart banner for our app. We also have 2 buttons in our site source to download/open the app from the page, which links with a specific appstore URL. I have a feeling this has something to do with this dialog but I don't know what.
Can anyone provide more information about this dialog? What can we do to prevent its appearance?
If it makes a difference, we're testing this mobile site with an iPad running iOS 7.
I've included this blurred out screen shot to focus on the unwanted dialog.
I got the same problem for IOS 9.0 and IOS 8.4 and after trying almost everything i found the solution. On click of button which shows this pop-up you must be doing some asynchronous call and on getting the response if you do window.open(someUrl) you will always get this pop-up. You can solve this by making that call sync or get the url even before click on the button and just do window.open with that url. I changed my call to sync this issue is solved.
I am using PhoneGap 2.9 on a Galaxy S3 Android 4.2.1 to develop an application. In the application i have overridden the default back button behavior. The back behavior is simply a call to :
window.history.back();
I have 4 html pages. After navigating all the way to page4.html, I hit the back button and successfully navigate to page3.html. On page3.html I must hit the back button twice in order to successfully navigate to page2.html. It seems to behave this way regardless of the navigation plot. The first "back" works fine, all subsequent ones require a double tap of the back button.
Stangely, when I put an alert("going back!") just before the call to window.history.back(),it displays properly for every "back" tap in the navigation. What could be causing this?
I'm not exactly sure how you are calling window.history.back() but you could do something like this:
$("#backButton").bind("click", backClicked);
function backClicked(){
window.history.back();
}
and I highly recommend incorporating the fastclick.js library to any project that you want responsive buttons.