Pressing back button does not suspend/terminate application - windows-runtime

I've created an app with secondary tiles. The tiles leads to Page2.xaml of the application. So when the user clicks it, the app opens on that page (Page2).
Ive added the following at the end of OnLaunch in app.xaml.cs:
foreach (string id in ListOfId)
if (id == e.TileId)
{
rootFrame.Navigate(typeof(Page2));
}
Pressing back button (hardwarebutton) leads back to Page1, the first page of the application. Thats the wanted behaviour. The problem is, if I then press back on the Page1 it only flips the page... seems to reload it?
If I start the application by its default tile that leads to Page1, and then press back button the app suspends (expected).
Can I trigger suspension of the app in code? I can override hardware back button and might solve my problem that way

Related

Location icon does not always disappear when app is minimized on Android

I use Codename One to code my app. I've defined my UserLocationListener and use it successfully with the LocationManager.
In the main class' stop method I set LocationManager.setLocationListener (null) and the location icon disappears when the app is minimized.
However I'm also using a MapContainer with setShowMyLocation (true) and when the app gets minimized from a form that does not show the MapContainer the Location icon remains in the Android (Nougat) bar. Same behaviour when I get back to the form with the map from a form without it and then minimize the app.
Please note that if I don't setShowMyLocation (true) the icon disappears from whichever form.
Furthermore in the stop method I setShowMyLocation (false) but it looks like the listener does not stop.
What can I do to ensure that the location goes off when my app is minimized?
Thanks in advance

Windows Phone Universal - Issue in Navigation and On Loading of page

I am facing a weird problem in windows phone 8.1 page navigation.
I have got two pages.
Login page > Consists of app bar in which one of the button take us to second page.
Second page is Cached using MVVM i.e Registered the Second page to IOC on launch of app and binding the instance of it to page 2 XAML.
In the Second page View model Constructor I am making Server call to get the data.
Problems facing.
On Clicking the app bar button to navigate to second page, the app stays in the first page until the second page make server call and get the response. Then its navigating.
But actual behavior must be it should navigate to second page and wait there to get response showing progress bar.
One quick fix is I made the thread to stop for some 50 millisecond in page 2 constructor of view model and then made service call
It navigated to Second page immediately and waited there until response but the previous page App Bar still displays until I get the response.
I even find the quick solution for it by Collapsing the App bar just before Navigating to that page.
I know these quick fixes are not good. So please help me to find out the problem or if you already know please revert back with the solution.
Don't use constructor to initiate the web service calls . Use OnNavigatedTo or Page_Loaded event .

Windows Phone Application Bar Instance Remaining Same When Back Key Pressed

I Have Created an application bar in the First Page and when a click occurs, it navigates to the Second Page and creates a new Application Bar in CodeBehind c#.
Till here it is Working fine but when i press the Back Hard Button while on the second page, the application bar instance is still remaining and appearing in first page.
In the ONNAVIGATEDTO method i'm making the instance of the first page appbar as null but it is not working and the previous application bar (of the Second Page) is still showing in the firstPage.
The application bar is different for each page. No need to create it in code behind.
The null assignment does not work because the appbar is not rendered yet. If you insist of doing it in code behind, which is not recommended, do it on page load. There is also an Items.Clear() method you can use to remove the app bar items. You should do it in XAML though.

Trigger.io active tab for tabbar

I have a tabbar in my trigger.io app and currently have the setactive parameter set on the function element for each tab, so when selecting a tab it highlights the tab. While this works as expected I noticed if I go back using the back button on android or a built in soft button in app
( history.back() )
The highlight is lost. Now I understand why it would get lost as its only explicitly told to highlight when tapped but I was wondering if there is a way to programmatically trigger the highlight or active state so when I navigate between tabs and use the back button it will keep the highlighted state properly for each tab section?
Easiest would probably to add an event listener to update the button state with:
forge.event.backPressed.addListener(callback, error)
Also see: https://trigger.io/docs/current/api/core/event.html

Caching if visit same page twice: back button only shows data from second viewing

I am creating a webpage and am having some issues with how the back button works on the page. I am guessing that I need to set some headers, but don't know which ones or how. This is what I'm seeing:
(1) Go to the main page, which shows forum threads.
(2) Click a link to go to a page showing a thread. On this page, scroll down and add a comment.
(3) Comment is saved via form (edit: I have tried both POST and GET form). The same thread page is now reloaded via a redirect. The comment shows.
In Chrome: pressing the back button at this point still shows the comment as having been added. It looks as though the back button didn't work. However, the page is scrolled down as it was for (2). Clicking the back button again shows the main page. So, the back button does take me back, but if the same page is there twice, it shows the new data both times.
In IE9: pressing the back button displays "Webpage has expired". Clicking it again takes me to the main page.
How do I alter this behavior so the back button truly shows me the previous page?
(The reason I'm doing this is that I keep track of how many pages I am from the main page so I can generate a "back to main page" link. (2) above has history.go(-1) and (3) above has history.go(-2). This won't work if the user presses the browser back button from (3) since it will now be 1 away from the main page, but show the link from (3).
In step (3) you probably have a POST that returns the new HTML of the thread page. Instead the POST should redirect to a GET of the thread page.
See http://en.wikipedia.org/wiki/Post/Redirect/Get