foreground

NotificationManager.cancel() doesn't work: Notification isn't removed

本秂侑毒 提交于 2020-01-02 02:51:28
问题 I've been trying to remove a persistent Notification set by a Service using: startForeground(1337, notification); The code I'm using to cancel it: NotificationManager nManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); nManager.cancel(1337); // cancel existing service notification, doesn't take effect nManager.cancelAll(); //surpluous, but also doesn't take effect To clarify why I am doing this: the Service starts with a default persistent Notification.

Close foreground thread gracefully on windows service stop

对着背影说爱祢 提交于 2020-01-01 15:05:23
问题 In my windows service I create one "parent" foreground thread that in turn spawns "child" threads using ThreadPool (which means they are background) to execute tasks. What is the best way to close foreground thread gracefully on windows service stop? Here is my current implementation (stripped out of task-specific logic): public partial class TaskScheduler : ServiceBase { private static AutoResetEvent _finishedTaskAutoResetEvent = new AutoResetEvent(false); //This flag is used to increase

How to bring a window foreground using c#?

◇◆丶佛笑我妖孽 提交于 2020-01-01 00:56:11
问题 I am trying to bring a window foreground. I am using this code. But its not working. Could someone please help? ShowWindowAsync(wnd.hWnd, SW_SHOW); SetForegroundWindow(wnd.hWnd); // Code from Karl E. Peterson, www.mvps.org/vb/sample.htm // Converted to Delphi by Ray Lischner // Published in The Delphi Magazine 55, page 16 // Converted to C# by Kevin Gale IntPtr foregroundWindow = GetForegroundWindow(); IntPtr Dummy = IntPtr.Zero; uint foregroundThreadId = GetWindowThreadProcessId

How to know if my application is in foreground or background, android?

孤街浪徒 提交于 2019-12-31 10:04:16
问题 I need to check if my application is running in background or foreground and then perform some operations relatively to it. I searched a lot and a clear solution is not available. Make a parent activity in its onPause() and onResume() methods keep some variable to update them accordingly. When you create any new activity inherit your parent activity. Although this is the best solution I feel to achieve my task, but sometimes if the power button is clicked even though application is in

How to know if my application is in foreground or background, android?

偶尔善良 提交于 2019-12-31 10:04:10
问题 I need to check if my application is running in background or foreground and then perform some operations relatively to it. I searched a lot and a clear solution is not available. Make a parent activity in its onPause() and onResume() methods keep some variable to update them accordingly. When you create any new activity inherit your parent activity. Although this is the best solution I feel to achieve my task, but sometimes if the power button is clicked even though application is in

Showing flashing LED for foreground activity / screen on

百般思念 提交于 2019-12-30 10:53:39
问题 I'm trying to turn the LED-flashing on for my activity in foreground, but it works only when the screen is off. Is it possible to turn the LED on for active activity with the screen on? My code: protected void led() { Notification notif = new Notification(); notif.ledARGB = 0xFF0000ff; notif.flags = Notification.FLAG_SHOW_LIGHTS | Notification.FLAG_ONGOING_EVENT; notif.ledOnMS = 800; notif.ledOffMS = 200; notificationManager.notify( LED_NOTIFICATION_ID, notif ); } 回答1: At first Android LED

Linux: Run cron job in foreground

孤人 提交于 2019-12-30 03:17:07
问题 In Linux, is there a way to run a cron job in the foreground (or interactive mode)? (I have a program that runs periodically to accept user input and do some processing. So I want to schedule it as a cron job that can run in the foreground). 回答1: Try this out on your user's crontab : @hourly DISPLAY=:0 xterm -e /path/to/my/script.sh It will open (hourly) an xterm with your script executing, and exit after your script exits. Of course, you should modify the @hourly part to suit your needs. 回答2

How do you force a java swt program to “move itself to the foreground”?

我与影子孤独终老i 提交于 2019-12-29 05:07:05
问题 Currently with swt, I sometimes want a program to arbitrarily come to the foreground (like an alarm clock might). Typically the following works (jruby): @shell.setMinimized(false) @shell.forceActive This brings the shell to the front if it was minimized. Creating a new shell at any time also brings the (new shell) to the front. So far so good, however, if the shell is not minimized, the above code just flashes (blinks) the app's icon in the taskbar. Well actually the first time you run it, it

Can I launch an app in Foreground when I enter an iBeacon range?

。_饼干妹妹 提交于 2019-12-28 06:54:30
问题 I'm creating an app for iOS using iBeacons. I know, that if i set up a region to monitor, the framework can invoke my app when I enter/exit a region, or turn on the screen inside the region. I've managed to create a local notification in this callback as well. My question is, whether is it possible to bring the app into foreground, like if it was launched by the user? 回答1: No, I do not believe this is possible. Apple's philosophy is that the user is in control of what app is in the foreground

Style to choose suitable foreground according to background color

白昼怎懂夜的黑 提交于 2019-12-24 07:06:09
问题 I have a WPF application which ships with a set of default styles for Label, TextBox etc. defined by item types (no explicit keys defined). Within the application there are two main containers used, one with dark background and one with light background, such that sometimes it's right to use black as the foreground color for a Label and sometimes its dramatically wrong. On the other hand, editors are always styled rather traditionally with light background and dark foreground, so I cannot