ResolveHostNameAsync breaks tombstoning? - windows-phone-7

I noticed an issue where calling DeviceNetworkInformation.ResolveHostNameAsync prevents the app from resuming from a tombstoned state. If you force tombstoning upon deactivation when debugging (via the project settings, debug tab), pressing the Windows button and then the Back button to return to the app causes the phone/emulator to display "Resuming..." and never actually return from the tombstoned state.
To test this, I created a new WP7.1 app and added a button with the following action:
private void Button_Click(object sender, RoutedEventArgs e)
{
DeviceNetworkInformation.ResolveHostNameAsync(new DnsEndPoint("google.com", 0), HostNameResolutionCallback, null);
}
For testing, my callback method doesn't actually do anything:
private static void HostNameResolutionCallback(NameResolutionResult result)
{
}
If you tap the button, exit, and then return to the app, it will display "Resuming..." until you press the Windows button again.
I am using the WP7.1 Beta 2 Refresh SDK.
Any ideas?

I suspect that you're starting the app with the debugger attached.
When you force tombstoning the process is being ended and so when you resume the emulator is waiting for you to restart the debugger so you can continue debugging the app.
This behaviour is by design. It is to allow you to continue debugging after tombstoning.
If you force tombstoning while debugging and the app appears to be stuck in the resuming state just hit F5 (Debug > Start Debugging) in Visual Studio to resume the app and the debug session.

Related

Pause Flutter app in debugger and wait for tap in IntelliJ

I'm trying to debug a Flutter app in the Android emulator by pausing it, tapping on a button and expecting the debugger to take me to the buttons onPressed event handler, where I want to step through the code.
When I tap the button, nothing happens and the debugger doesn't change from paused to running. However, if I resume the app after tapping the button, the onPressed event handler is immediately invoked, so obviously the tap is being picked up by the emulator while the app was paused.
How can I debug my app in this manner, instead of manually finding the correct .dart file and the correct button and inserting a breakpoint?
Unfortunately you cannot do exactly that. Pausing the app prevents the event loop from executing and your button handler is not called. Making it pause in any of your code requires a new feature in which IntelliJ can differentiate between your code and framework code, and stop at any invocation of your code (even then, it should ignore your build() functions). The closest thing to that I could find in IntelliJ is Java method breakpoints, which would not work with Dart.
However, here is one thing you can do: You can set up a breakpoint in the caller of onPressed, which would pause your app on any button press. Here's where you can place that breakpoint:
// This is Line 504 of flutter/lib/src/material/ink_well.dart
// Ctrl+click on button to go into the framework code
// and find this file in project explorer
void _handleTap(BuildContext context) {
_currentSplash?.confirm();
_currentSplash = null;
updateHighlight(false);
if (widget.onTap != null) {
if (widget.enableFeedback)
Feedback.forTap(context);
widget.onTap(); // <---PLACE BREAKPOINT HERE
}
}
Once you hit this breakpoint, click step into (F7) a couple of times and you should get to your onPressed.

Windows 10 UWP app - Back button only works when pressed the second time

I am developing a Windows 10 UWP app with Visual Studio 2015. I am working on the back button functionality right now. Unfortunately there is a problem. When I press the back button (either on a Phone or on the PC) it doesn't go back to the previous page. When I press it again it works.
It is like this example:
Start App (page 1)
Go to page 2
Go to page 3
Click back button (nothing happens)
Click back button (it goes to page 2)
Click back button (it goes to page 1)
So the first time when you want to go back it needs two presses... why? Additionally I've found out that the first press doesn't trigger the back button event. But why?
I am using the implementation as described in this article:
http://www.wintellect.com/devcenter/jprosise/handling-the-back-button-in-windows-10-uwp-apps
It has to do with SplitView staying open and holding the back event. You should close it if you are using it as overlay.
private void SettingsButton_Click(object sender, RoutedEventArgs e)
{
this.SplitView.IsPaneOpen = false;
Frame.Navigate(typeof(SettingsPage));
}

restart emulator behavior in Windows Phone 7

I have a question about the expected behavior of Window Phone 7.5 emulator.
If I deactivate (start button), close (back button from first screen) or tombstone my data (selecting this option in VS first and then in the emulator clicking start button), and then press Stop Debugging (Shift+F5) in VS, all changed data in my app for that session is retained when I start the debug process again (F5).
However, when I just changed data in my app in the emulator and don't actively deactivate, close or tombstone my app, and then press Stop Debugging (Shift+F5) and then Start Debugging (F5) the changed data is not retained. I've noticed that upon stopping debugging, neither the Application_Deactivated or Application_Closing occur as well.
Is this expected behavior when starting/stopping the debugging processes? I'm asking because I need to know if this has any effect in the real world, like for example if I'm in my app and make a change and then someone turns off the phone completely right then and there and turns it back on, will my data be retained
This is expected. What you are doing is effectively crashing your app. If the phone/app is shut down in a normal situation then Deactivated or Closing will be invoked.

How to disable back button of windows phone after one click

I have a problem in my app is that when the user hit back button multiple times the app become crashed.Is there any way to handle this problem ?Is any way to disable back button after the first click from a page.so further click can be avoided.The exception i am getting while hitting back button multiple time is 0x8000ffff.Is there any solution for this in windows phone 7.1?
You should fix the issue which is causing your app to crash. If you disable the back button behaviour you risk failing marketplace certification due to requirement 5.2.4[.1] http://msdn.microsoft.com/en-us/library/hh184840(v=VS.92).aspx
You can control that, here is a sample code:
private void YourPage_BackKeyPress(object sender, System.ComponentModel.CancelEventArgs e)
{
//App.NaviService.BackKeyPress(sender, e);
if (NavigationService.CanGoBack)
{
NavigationService.GoBack();
}
}

Pressing the device's back button do we have to close the Message box and cancel the backwards navigation too in WP7?

In the Certification guidelines 5.2.4 C they mentioned that if the current page displays a context menu or a dialog, the pressing of the Back button must close the menu or dialog and cancel the backward navigation to the previous page.
Is this applicable for MessageBox also?
I am using MessageBox to prompt the user to allow the location service api to use location i.e. lat and long which is in application launching.
Do I have to follow the 5.2.4 C for the MessageBox too be closed and stop back navigation.
Please guide me for standard way to implement so not to fail in Windows phone 7 Certification process.
4.Check the Back button Twice:
protected override void OnBackKeyPress( System.ComponentModel.CancelEventArgs e )
{
if (DemoPopup.isOpen)
{
e.Cancel = true;
//hide the popup
DemoPopup.IsOpen = false;
}
else
{
base.OnBackKeyPress(e);
}
}
Yes, if you have a Message Box displayed (or a Context Menu) then pressing the back button should dismiss the Message Box instead of navigating backwards, i.e. backwards navigation should not occur.
However, in the case of MessageBox.Show and ContextMenu (from the Silverlight Toolkit), I think this happens for you automatically.

Resources