How to Exit From the Application in windows phone 7? [duplicate] - windows

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Windows Phone 7 close application
How to Exit from the app when user presses Back Key Button from Device??
Thanks,
Balaram.

This is handled automatically for you.
<slightly simplfied answer>
The back button gives access to the navigation system within the application. If there are previous pages to return to, the back button will take you back to the most recent previous page. If there are no previous pages, the application will exit. You don't need to do anything to make it exit.
</slightly simplfied answer>

Here's how I do it:
void Exit()
{
while (NavigationService.BackStack.Any())
NavigationService.RemoveBackEntry();
base.OnBackKeyPress(new CancelEventArgs());
}
Best of luck to you.

This is handled automatically for you if you are on the first page the app began with.
Now you can override the backkey press event but you run the risk of not passing certification when you submit the app. The backkey is meant to go to the previous page of the application, and exit if its the first page. Microsoft does have exceptions to this, such as pausing a game, but other than that it has to stick to its intended purpose.

You can always call an exit by doing this at your landing page use this code on click of your application back button:
if (NavigationService.CanGoBack)
{
while (NavigationService.RemoveBackEntry() != null)
{
NavigationService.RemoveBackEntry();
}
}
This will remove back entries from the stack, and you will press a back button it will close the application without any exception.

If you really want to do Exit, you can throw an unhandled exception and your app will close. But it is a very bad thing to do!

Related

Detecting when the "Thank you" message has been dismissed after IAP OSX

I am working on a game on OSX with In App Purchases.
I am trying to detect when the Popup that says "Thank You, Your purchase was Successful." At the end of a successful Purchase by the user.
The Problem that I am having is I need to hide the mouse and resume input on the game after this message has been dismissed, but I can't find a suitable place to do this.
How can I find out if the OK button has been pressed on this message box?
Okay, so I found a fix to my problem.
I couldn't find a way to detect when an alert is shown from another Application, as all the the In App Purchase popups come from the App Store.
The fix I used was to make sure that the App Store was open before starting the transaction. This means that OS, whether or not you are in full screen, will automatically take you to the App Store. This causes the Alerts to be shown as sheets inside the App Store rather than in front of your application. Problem solved.
I open the App Store immediately before instigating the transaction by calling this line of code:
[[NSApp mainWindow] makeKeyAndOrderFront:[NSApp mainWindow]];
Then once the transaction finishes I grab focus on my App again.

Need to display a busy window on max with spinner

I'm a new Mac programmer writing my first mac app, actually porting an existing iOS app to MAC.
The app does a lot of remote communication, so when the user kicks off an operation, I want to display a busy window (or message box, or NSAlert maybe), until the operation is completed, then dismiss it programmatically, or the user can click cancel to stop it.
The busy window prevents the user from doing anything until that operation is completed.
The busy window should have a progress spinner, some text, and a cancel button.
Its such a simple thing yet I'm having problems with it because I dont really know MAC programming, getting myself frustrated.
Can anybody offer suggestions, or already written code for it. I hope some code for this already exists because I cant believe I'm the only person in the world who needs things kind of busy window.
Thanks for any help.
You mean something like this:
http://www.developers-life.com/example-nspanel-with-nsprogressindicator.html
???
Source code is available, too (link at the end of the article).
You can just modify the NSPanel in Xcode and add a "Cancel" button that you connect to your cancel action.

How to shut a Win app from another app without reboot?

Hi I want to make a small test window app that can force IE to save its data and shutdown upon a button click and restart with same tabs when another button is clicked??
I am fairly new to Win32 programming can anyone help me out here.??
Any leads will be appriciated??
Try to find one of each browser class with EnumChildWindows then you save the text(current link) of each one, and send a WM_CLOSE message to the program, if you debug the IE you'll probably see a CALL to the function to open a new window, when you find it, you can call it again and with the new browser class you put the text you got from the one that was opened

Why does Application_Deactivated not get called on a pivot page?

For my Windows Phone 7 app, I have a main panorama page which opens up into a pivot control. The main panorama page correctly calls Activated/Deactivated, and restores correctly.
But after visiting the pivot page, pressing the Windows key doesn't call Deactivated.
When the app is relaunched with the back button, it goes right to how the page looked before tombstoning, but Activated is not called, and the page is not usable, and the back key doesn't work.
Has anyone else experienced this problem before?
If you just go to the Start screen then your application MAY not get tombstoned. This is expected behaviour.
If you open another application or open search from within your application you should experience tombstoning.

Close a WP7 application programmatically? [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Windows Phone 7 close application
How do I programmatically close a WP7 application?
You can always call an exit by doing this at your landing page use this code on click of your application back button:
if (NavigationService.CanGoBack)
{
while (NavigationService.RemoveBackEntry() != null)
{
NavigationService.RemoveBackEntry();
}
}
This will remove back entries from the stack, and you will press a back button it will close the application without any exception.
Acknowledging known solutions to provide "Exit" buttons, currently I do not see a compelling reason to implement an "exit" from a WP7 application.
The platform is fully capable of managing closure of apps. The more apps don't provide an exit, the quicker users will become accustomed to not thinking about app house keeping, and let the platform manage it.
The user will just navigate their device using start, back, etc.
If the user wants out of the current app to go do something else quickly - easy - they just hit start.
.Exit(), whilst available for xna, really isn't required anymore either. There was a cert requirement during CTP that games had to provide an exit button. This is now gone.
Non game apps never had the need to implement this.
The more this topic's discussed (and it really has been given a good run around the block), the more the indicators to me suggest there is no need to code an exit.
It should also be mentioned the app cert reqts are specific that apps should not have unhandled exceptions.
There isn't really a good way to do it. There is a nice explanation/overview of your options here.
For short, if this is a Silverlight app (not XNA), it is not supported. You can simply throw an unhandled exception, and the app will quit. I wouldn't recommend that, it seems like a hack and a rather crude way of doing it.
Here is a way to make it look nicer, but at the end of the day it still throws an exception. I don't know if the application certification process looks at whether you are throwing unhandled exceptions, but I guess it could be an issue.
Simplest thing to do is simulate back from your root/home page. I'm guessing this is exactly what apps (those which have quit button) like Fruit Ninja do.
if ( NavigationService.CanGoBack )
{
NavigationService.GoBack();
}
Btw, above snippet works for a silverlight app.
Another way to exit the application is calling the exit function of the Game class of Microsoft Xna framework.
For example:
Microsoft.Xna.Framework.Game game = new Microsoft.Xna.Framework.Game();
game.Exit();
private void exitBUtton_ONclick(object sender, RoutedEventArgs e)
{
throw new Exception("ExitAppException");
}

Resources