foreground

How to be notified when foreground (top) activity (application) changes

谁都会走 提交于 2019-11-27 12:19:15
问题 I want to write a service for Android platform that is notified when the current foreground activity changes. Basically the service should do some tasks only when the top activity changes. Is there any way to subscribe and to be notified when this kind of event occurs ? Or there is no possibility and the service should poll from time to time the list of running activities and to check what is the foreground activity ?Not preferable solution... 回答1: AFAIK there are two ways to do that. Start a

Is there a foreground equivalent to background-image in css?

拜拜、爱过 提交于 2019-11-27 11:27:42
问题 I want to add some shine to an element on webpage. I would prefer if I don't have to add additional html to the page. I want the image to appear in front of the element rather than behind. What's the best way to do this? 回答1: To achieve a "foreground image" without extra HTML code, you can use a pseudo-element ( ::before / :before ) plus the CSS pointer-events . The last property is needed so that the user can actually click through the layer "as if it did not exists". Here's an example

iOS how to judge application is running foreground or background?

房东的猫 提交于 2019-11-27 11:11:17
问题 As we all knows, if an iOS app is running foreground, then the app won't notify users when the remove notification come. Now In my app, I want to show alert to notify users that remote notification comes. How to judge if the app is running foreground or background? I have found the docs and searched stackoverflow.com and failed to find any thing about that. Thank you. 回答1: [UIApplication sharedApplication].applicationState will return current state, check it possible values and don't create

How to determine if an Android Service is running in the foreground?

懵懂的女人 提交于 2019-11-27 04:05:13
I have a service which I believe to have running in the foreground, How do I check if my implementation is working? piotrpo private boolean isServiceRunning(String serviceName){ boolean serviceRunning = false; ActivityManager am = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE); List<ActivityManager.RunningServiceInfo> l = am.getRunningServices(50); Iterator<ActivityManager.RunningServiceInfo> i = l.iterator(); while (i.hasNext()) { ActivityManager.RunningServiceInfo runningServiceInfo = i .next(); if(runningServiceInfo.service.getClassName().equals(serviceName)){ serviceRunning =

START_STICKY, foreground Android service goes away without notice

假如想象 提交于 2019-11-27 03:30:31
问题 I have started a service in my new application. The service is foregrounded, with a Notification. When this is run in the AVD 2.1 API Level 7, all works fine. But when it's run on a Samsung Galaxy Tab running Gingerbread, the service will start (the icon and app name appear at the top of the notification area), but after a few seconds, the service disappears. The last entry in the Log that I can see is associated with my App, is the result of my Log.d("Taglines","Returning with " + START

startForeground() does not show my Notification

拈花ヽ惹草 提交于 2019-11-27 01:44:18
问题 I am trying to make my Service running in foreground. I tried to use this example (please look for the section " Running a Service in the Foreground "), but startForeground() does not actually show my notification. And no exceptions is thrown. To make it shown, I need to use NotificationManager like here explained. With NotificationManager my notification works, but i'm not sure that my Service is foreground after this "silent" call to startForeground() . What can be wrong? EDIT : I just

How do I update the notification text for a foreground service in Android?

断了今生、忘了曾经 提交于 2019-11-26 23:57:14
问题 I have a foreground service setup in Android. I would like to update the notification text. I am creating the service as shown below. How can I update the notification text that is setup within this foreground service? What is the best practise for updating the notification? Any sample code would be appreciated. public class NotificationService extends Service { private static final int ONGOING_NOTIFICATION = 1; private Notification notification; @Override public void onCreate() { super

iOS NSNotificationCenter to check whether the app came from background to foreground

倾然丶 夕夏残阳落幕 提交于 2019-11-26 22:03:13
问题 I have a situation in which i have to intialize an object everytime when it comes from background to foreground and that should be using the NSNotificationCenter not with appdelegate because iam building a static library so there wont be appdelegate with that so please help me in the same. 回答1: Have you tried UIApplicationWillEnterForegroundNotification ? The app also posts a UIApplicationWillEnterForegroundNotification notification shortly before calling applicationWillEnterForeground: to

Bring window to front -> raise(),show(),activateWindow() don’t work

橙三吉。 提交于 2019-11-26 21:09:46
问题 In my Qt-application I open a URL in the default-browser. Afterwards I want to bring the main-window of my application to the front again. I tried all approaches I could find but none worked. All it does is blink in the taskbar (of Window 7) Here’s an example: this->viewer->show(); this->viewer->raise(); this->viewer->activateWindow(); *viewer is a pointer to a QmlApplicationViewer which is derived from QDeclarativeView 回答1: This problem is specific to Windows. If the active window belongs to

How do I get tcsetpgrp() to work in C?

南笙酒味 提交于 2019-11-26 20:57:12
问题 I'm trying to give a child process (via fork() ) foreground access to the terminal. After I fork() , I run the following code in the child process: setpgid(0, 0); And: setpgid(child, child); In the parent process. This gives the child its own process group. The call to setpgid() works correctly. Now I want to give the child access to the terminal. I added the following to the child after the setpgid() call: if (!tcsetpgrp(STDIN_FILENO, getpid())) { perror("tcsetpgrp failed"); } After that,