I'm creating a WP7 app that needs to continue running when the user is not using the phone - ideally the user sets it going, locks the phone and carries on with their life.
Is this possible?
I know it is possible to disable the lock screen, so if the user were to just leave the phone on a table it would be fine and carry on running. The problem is when they put it in their pocket - buttons will get pressed such at the windows/home button, and if this happens then the app is tombstoned straight away.
Any ideas if this is possible? Either somehow locking the phone without tombstoning the app, or implementing a sort of custom lock screen and handling the events for all the hardware buttons including the windows/home button?
Any suggestions will be appreciated.
Just as you figured out:
PhoneApplicationService.Current.ApplicationIdleMode = IdleDetectionMode.Disabled
No need to ask user for permission anymore (since the original 6.3.1 "Configurable Functionality" was dropped). However, there are other Marketplace certification requirements to consider, see section 6.3: http://go.microsoft.com/fwlink/?LinkID=183220
I think I've done it again - asking questions too soon.
I believe the following setting:
PhoneApplicationService.Current.ApplicationIdleMode = IdleDetectionMode.Disabled
will enable the application to run under a lock screen.
Related
We are creating an application(must be UWP for Microsoft app store). The application will remain running and we want to “hide” the UI from the desktop after they log in (not in taskbar). We want to put it somewhere where they can see the status of the application and/or logout (like a VPN or Anti-virus app shows status).
We have investigated using systray (non existent in uwp), quick actions tray (seems to be for system applications), notifications (show status there, but user can remove it—looking for something like the Action Center buttons for Wifi). Our goal is to have an application running, but out of the way, with access to the status and logout functionality. What is the Microsoft approved way? If there is no such approved way, how have you solved this?
At this point, that's not supported in UWP.
You can however publish WPF applications to the Microsoft Store using Desktop Bridge. I haven't touch it, but I've seen a few apps in the store running more elevated access than UWP and you may have the ability to control the visibility of the application's icon (ie taskbar/systemtray).
Give it a try and let us know if it works.
You're right, but there are some workarounds that can be used:
1. USING THE DISMISSED EVENT to show the notification again if user dismissed it.
2. UWP APP WITH SYSTRAY EXTENSION
As explained in this blogpost, you can add a component that will create the tray icon.
What I need is to provide an exit confirmation dialog for my mobile app.
The dialog is to appear when users taps the Back button on their phones. I know two options i.e.
"Press back again if you really wish to exit" type of message.
"Do you really wish to exit + Yes/No" dialog.
I am exploring the second variant.
The problem I see primarily concerns the windows store apps.
If I show it and give user time to decide than I have already cancelled the default behavior.
For windows store app it is Windows.Phone.UI.Input.HardwareButtons.BackPressed i.e. I've set the Windows.Phone.UI.Input.BackPressedEventArgs.Handled to true.
What do I do if user clicks Yes i.e. confirms his intent to exit the app?
I've read the Metro App can no longer be programmatically killed and do understand that programmatically closing the windows store app is considered "unacceptable". Does it mean that such an exit confirmation dialog is banned for windows platform?
What about Android? Is it ok there to exit the app programmatically?
Formally Windows Store Policy does not allow such behavior:
Where applicable, pressing the back button should take the user to a previous page/dialog. If the user presses the back button on the first page of the app, then the app terminates (unless it is allowed to run in the background).
So you might be lucky to pass certification, but it is definitely not recommended behavior.
For "testing purposes" there are two methods exposed in API to programmatically exit application:
High-level Application.Current.Exit()
Low-level CoreApplication.Exit()
Technically you can use one of these methods to force application to close after user confirmed to exit. But there is no guarantee that you will pass certification.
For Android there are also guidelines. In particular the Core App Quality guide says that
App does not crash, force close, freeze, or otherwise function abnormally on any targeted device.
There are various discussion on Stack Overflow on how to correctly close Android app (example).
From my experience such apps do path certification, but Play team may choose to not promote them as they don't follow official design guidelines.
You could by using the onBackPressed callback method and showing a dialog, but as Jason said, it is a bad practice on Android too.
Let me explain why.
The OS has a PackageManager which manages every apps on the device. Apps have a priority level. That's why the phone app opens when it receives a call and yours get paused (in background). If the active app with the highest priority level needs memory or if your device encounter any problems, it can destroy your activities and then close your app automatically.
Say I have started application on Windows (created in WPF for .NET in case that would help), that opens some windows/panels and just runs in a background. User don't want to interact with it constantly, however once in a while needs to urgently execute some actions in it.
Is it possible to bind some key shortcut e.g. alt+key to running application, so on hitting it app gets focus? It doesn't necessarily need to be brought to front, altough that would be nice as well.
"a hotkey that works out of your application" is this what you want?
if so, you need global hotkey that i can reference to!
(Sorry i didn't have enough reputation for commenting!)
I think I found sort of semi-solution, that doesn't need any coding or changing any system settings, but only:
1) keyboard with Windows key
2) possibly forcing user to re-arrange icons on his task bar (or pin my application as one of first 9 applications on his taskbar)
pressing WinKey+digit brings up digit'th application from the taskbar. Pressing it again hides it.
This works for Windows 7.
Obiously doing this way is a bit lame and not customizable at all, but it's always something... Still happy to find better way if there exists such.
I am writing an application in c# to lock or freeze all programs untill user enters a value in the app's textbox and clicks ok.
The purpose of the app would be to get people to enter their time.
As far as I know you can set it to top most but they can end the app with task manager so am stuck here..
formName.TopMost = true;
Any help would be appreciated
Yes, that's correct. The Windows operating system allows multiple programs to run at one time. What you're experiencing is entirely by design.
If I remember correctly, the TopMost property applies only to windows in your process, and as you mention, it's all quite irrelevant: the user can still kill your application using the Task Manager.
There's no legitimate way of getting around that. It's not a "limitation", it's a feature. Any app that prevents itself from being closed by the Task Manager is treading dangerously closely on the category of software that we call malware. Nothing good can come out of pursuits like this.
Relevant reading: The arms race between programs and users
Perhaps a good compromise solution is to make your window/form actually top-most and disable the Close button so that the user knows they shouldn't try and close it. This is almost always enough to stop a user that is not determined to end your application by any means necessary, and that's about all you should ever be concerned with.
See the sample code here for how to make your window/form always appear on top of other running applications by setting the WS_EX_TOPMOST flag or toggling HWND_TOPMOST.
I've also already written a detailed answer here about disabling the Close button the correct way by setting the CS_NOCLOSE class style.
I have integrated a small to-do list in my WinForms application, where-in user can add tasks and set alarm for it. Is it possible to run timer (or alarm clock counter) in background, even if application is closed. I am using the AlarmClass written as answer here. The aim is only to show a MessageBox when the alarm time is reached and nothing else to do with the application. Also multiple alarm setting should be possible.
I am sorry if my question is not elaborated, coz I dont know wat other details I must include. But ready to reply your questions.
Thanks in advance.
Edit: Any comments on this link?
Short answer
No. If your application is shut down, there's no good way.
Long answer
Yes if you resort to clever hackery. You could:
Run your app in the system tray / background when the 'X' button is clicked
Run a scheduled task which launches your app in "alarm-checking" mode every N minutes
Write a windows service which launches your app for alarm events
I'm not sure, but can't you create a Windows application which only shows up in the Systemtray. Add the required keys to the registry to make sure it will automatically start when windows starts.
Otherwise you can split it up into two separate applications;
- Windows Application to manage the alert
- Windows Service to do the check in the background