foreground

Detect when app is killed from recent apps list in android O and P

我是研究僧i 提交于 2019-12-10 17:42:28
问题 Use case is I have to send logout request to server when app get killed from recent lists. I use onTaskRemoved to handle that however in Android O and P I get notification bar saying "app is running" that I want to avoid. Here is how I run foreground service: if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); channelId = "my_service_channel_id"; String

How can I change the Foreground color of a TextBlock with a Trigger?

♀尐吖头ヾ 提交于 2019-12-10 15:52:36
问题 I want to change foreground color of a TextBlock from dependencyproperty. But I don't change textblock color. I don't know this problem in my code. How can I change the foreground color of a TextBlock with a Trigger? XAML: <TextBlock Name="TestBlock" Text="Test color" > <TextBlock.Style> <Style TargetType="TextBlock"> <Style.Triggers> <Trigger Property ="IsMouseOver" Value="True"> <Setter Property= "Foreground" Value="Gray"/> </Trigger> <DataTrigger Binding="{Binding Path=TestColorMode2,

Getting current running application

99封情书 提交于 2019-12-09 19:39:50
问题 How may I get the current running application? I want to check if the application is running or not in service. I used the following code for that. ActivityManager activityManager = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE ); PackageManager pm =getPackageManager(); procInfos = activityManager.getRunningAppProcesses(); But it is returning me list of several applications, even if I pressed back button on their home screen. The running app list is still showing them in the list.

Android background service to determine foreground application

喜欢而已 提交于 2019-12-07 12:31:51
问题 I'm working on an application that will monitor the phone usage throughout the day. To do this I have a background service that starts on device boot and keeps on polling to find out what the current foreground application is. The following code works when I am just clicking an application then backing out of it and clicking another application. Now lets say I open the browser and go to a different webpage, it will stop registering the browser as being the foreground application. Or for

android: how to call activity by clicking foreground service notification

拈花ヽ惹草 提交于 2019-12-06 13:02:37
I start a foreground service which shows a notification. If my activity is hidden I want it start by clicking on the notification. A function called in onStartCommand does this: startForeground(noti_id, mNoti); The notification appears and works but it doesn't reactivate my MainActivity: notiIntent = new Intent(this, MainGate.class); notiPendingIntent = PendingIntent.getActivity(this, 0, notiIntent, PendingIntent.FLAG_UPDATE_CURRENT); MainGate.class is the activity which starts the foreground service. It should appear when I click on the notification. EDIT: Actually, it worked when the

How to monitoring app swaping in foreground?

社会主义新天地 提交于 2019-12-06 09:29:53
when my application run in background. It need to monitoring others application swaping in the foreground and get their name. How to implement? i.e. When an app goto the foreground. My app must be notified. then gets its name. For monitoring other Applications you can use ActivityManager for getting current top Appliction for Activity Stack as in Your Appliction: ActivityManager am = (ActivityManager)context.getSystemService(Context. ACTIVITY_SERVICE); List<ActivityManager.RunningTaskInfo> processes1 = activityManager.getRunningTasks(1); ComponentName componentInfo = processes1.get(0)

NSRunAlertPanel shows up behind the “active window”

北城余情 提交于 2019-12-06 08:39:58
I'm trying to put together a simple error reporting package. If my main program crashes, it saves a crashlog, then starts a reporter program. The reporter program asks the user if it can send the crash log to me, then does so. I'm using NSRunAlertPanel to create a basic message box. For some reason, that message box is showing up buried underneath any other windows that may be open. Run the main package from a Finder window, it shows up on top, force it to crash, the reporter window shows up behind the Finder window. Why is this happening, and how can it be solved? Minimal test case: #import

Android 自定义View实现画背景和前景(ViewGroup篇)

空扰寡人 提交于 2019-12-06 07:09:16
在定义ListView的Selector时候,有个drawSelectorOnTop的属性,如果drawSelectorOnTop为true的话,Selector的效果是画在List Item的上面(Selector是盖住了ListView的文字或者图片),即Foreground前景。如果drawSelectorOnTop为false的话,Selector的效果是画在List Item的下面,即Background背景。由于项目中恰好需要自定义View,需要实现此效果。 本文借ListView的代码来剖析一下, ListView完成此部分功能在frameworks\base\core\java\android\widget\AbsListView.java文件中。 用mSelector即ListView要画的Selector(资源文件),而mSelectorRect则是想要画的区域。 /** * Indicates whether the list selector should be drawn on top of the children or behind */ boolean mDrawSelectorOnTop = false; 决定画前景还是背景 /** * The drawable used to draw the selector */ Drawable

Changing Foreground of a TreeViewItem upon selection

两盒软妹~` 提交于 2019-12-06 01:31:40
In my program I have a TreeView in which the user will select different items from. There are a few items in my TreeView that are customized upon creation in my c# code-behind. Like so: public static TreeViewItem newItem = new TreeViewItem() //Child Node { Header = new StackPanel //ICON { Orientation = Orientation.Horizontal, Children = { new Border { Width = 12, Height = 14, Background = Brushes.Blue, BorderThickness = new Thickness(1.0), BorderBrush = Brushes.Black }, new Label { Content = "Node1" } } } }; I would like these items to display WHITE foregrounds when they are selected (just

Android background service to determine foreground application

我是研究僧i 提交于 2019-12-05 20:03:54
I'm working on an application that will monitor the phone usage throughout the day. To do this I have a background service that starts on device boot and keeps on polling to find out what the current foreground application is. The following code works when I am just clicking an application then backing out of it and clicking another application. Now lets say I open the browser and go to a different webpage, it will stop registering the browser as being the foreground application. Or for example, I open up google talk, it will register it as the current activity, but when I send a message it