Is it possible to prevent my Windows Phone app from closing? - c#

Is it possible to prevent my WP7 app from closing? I know how to override the back button, but is it possible to do the same for the start and search buttons? I am aware that preventing it from closing would cause it to fail certification, but this is a personal app that will not be submitted to the store.

Applications can override only Back button.
Both Search & Start buttons are not available for third-party applications.

Related

Preventing UWP from shutting down by pressing ‘B’ button on XBOX – XAMARIN

There is a post in stackoverflow that covers my research in this matter so far: How to do job while the application is exiting in UWP?
I found this solution in several searches about the preventing UWP from closing and it works, I know I’ll have to ask for approval before I submit my app to Windows Store to use Restricted capabilities to use it, but it is ok.
But the point is: I’m writing an app to run in Android, iOS and UWP platforms, in UWP the ability of the user to close the app in a PC is quite alright but closing the app in XBOX by accidentally press button B in the Gamepad control is a very annoying issue that I want to prevent!
The post mentioned before cover the problem to UWP app in a pc, with is not an issue for me because if the user clicks the X in the up-right corner of the window it alright that the app closes, but if the user press B button of XBOX controller accidentally and the app closes immediately, it is a very rude event of user experience, and I want that out of my app.
So, the post I mentioned before works fine for a PC, but it does not work at all in an XBOX series S. My question is how can I solve this issue? I’m sure that is not a UFO thing because every game bought in the store have this issue solved!
How can I do the same?
I figure it out: preventing XBOX button B is about disable back button not about intercept a close request.
So, the only thing is needed to be done is to add:
protected override bool OnBackButtonPressed() => yes;
to the page where the back button is meant to be disables

Windows Phone 8 resume/suspend /activated/deactivated

I am currently trying to make an app that takes some data from a server. I have a list and I am populating it when I login with some data. The idea is that that data can change over short periods of time. I made an auto refresh button, works fine, but I wanted to implement something like this:
When you open the app, everything loads, is good (done).
If you minimize (put in taskbar, I don't know how to say, enter on another app or menu). Your app will be suspended. When you resume it, I want it to perform the refresh thing. (Need help).
I'm currently working with Windows Phone 8, started project on this one and want to finish with this one. App.current. doesn't have resume or suspend, which I have found on lots of YouTube videos or on the MSDN site. Therefore I think I should do something with activated / deactivated, but I don't know where to add this handler. On the MSDN site I only found the function.
I am looking for something like this: Event on returning to app, after exiting by Windows key [UWP][Win10 Mobile], but as I told, I don't have this.suspend / this.resume on Windows Phone 8.
If we talk about Windows Phone 8, we have to specify which app flavor is intended.
For Silverlight apps, there are Application_Activated() and Application_Deactivated() methods, usually they're auto-created automatically in the App.xaml.cs
For so called "RT apps" there are events Suspending and Resuming, 1st one is subscribed automatically in the App.xaml.cs (so just put your code into that auto-generated handler), and you have to subscribe to 2nd one by yourself.

How to detect and handle external process

I'd like to know with a .net language(C# or VB) if I can detect when a new app is launched.
e.g: an user opens Firefox.exe from desktop (not from my app!), is it possible to detect this event from my app? Also is it possible to "pause" it before running it?
So for example when an user double-clicks an application, my app comes first and then it displays a message if he is sure to open that file with Yes and No buttons.
I don't need all code, I just need to know how to catch that event that can happen anywhere in system.
There are some Windows API functions in user32.dll that you can use in your .NET application through System.Runtime.InteropServices.DllImport to get the information you're looking for. Take a look at GetWindowThreadProcessId. For sample code, see http://www.c-sharpcorner.com/UploadFile/satisharveti/ActiveApplicationWatcher01252007024921AM/ActiveApplicationWatcher.aspx. Because applications tend to become active when they are launched, you'll find that the techniques used in that example will cause it to detect new app launches.
That doesn't answer the question about letting the user confirm whether they want to run an app, but it will get you part of the way towards what you are trying to do.

Close Button on VS11 Apps

I try to create an Application on Windows 8 with VS 11 with C#, And I need to a Button in my App that when people Click on this button , my App going to Close.
But I can't find any Exit or Close function to add, to my Click Event.
how can I make this button? or what is your proposal to solving this Problem?
You shouldn't close your app.
This is one of the concepts of Metro apps.The user switches to a different task and the
Process Lifetime Management aspects kick in, first suspending your application and then later, if needed, terminating it.
Don't close the application's window: let the user know that there is no information currently available and then let them switch away, close, or wait as they'd prefer.
Took from here
If you don't care about certification - e.g. you want a close button in your own debug build to help you with testing - you can call Application.Current.Exit()
You must not implement Close Button.
If you do so, your app will be not able to sell in the store. See "Certification requirements for Windows apps".
3.6 Your app must use the mechanisms provided by the system for those features that have them
(snip)
Your app must neither programmatically close nor offer UI affordances to close it.
You want this?
App.Current.Exit();
Try this.. It worked
App.Current.Terminate();

Start C# application on Windows Startup and keep focus [duplicate]

This question already has answers here:
Keep window on top and steal focus in WinForms
(5 answers)
Closed 9 years ago.
I'm developing a simple program that reads a card or a barcode and logs that on a database. Before, I developed the same application in Visual Basic and it was working great, but due to a lot of changes on our servers, we decided to develop this app in C#.
I can get my application to start with Windows putting its shortcut on 'startup' of the start menu but the problem is that its not getting focus so that the cards and barcodes can be read and that way my program is simply useless. The machines we use are running Windows XP and Windows 7.
How is the best way to start my application on Windows Startup and keep the focus in it?
This is, in general, a pretty bad design. I just finished a project involving barcode readers and set them up to act as serial ports, instead of keyboards. You should check whether this is an option with your hardware, as the end result will be much more reliable.
That being said, you can create a timer in your form that executes this.Focus() and this.BringToFront() to steal focus. Be aware that this will, by default, only cause the task bar to flash. You'll need to use TweakUI to enable focus stealing.
Another option is discussed here on SO. Very similar question, actually. Basically, you hook the keyboard input at a low level.
Please try and find another way, monitor system events or use a polling mechanism.
Stealing focus should be avoided, read this to understand why
If I had a dollar for every time I typed a password, cleartext in the wrong application because it stole focus...
On Form Activated Event call This.SentToBack()

Categories

Resources