众所周知,如果iOS应用程序正在运行前台,那么应用程序将不会在删除通知到来时通知用户.现在在我的应用程序中,我想显示警告以通知用户远程通知到来.如何判断应用程序是运行前台还是后台?我找到了docs并搜索了stackoverflow.com,却找不到任何相关内容.谢谢.
我有一个服务,我相信它已经在前台运行,我如何检查我的实现是否正常?
在我的Qt应用程序中,我在默认浏览器中打开一个URL.之后我想把我的应用程序的主窗口再次放到前面.
我尝试了所有可以找到的方法,但都没有用.它只是在任务栏(窗口7)中闪烁.这是一个例子:
this->viewer->show();
this->viewer->raise();
this->viewer->activateWindow();
Run Code Online (Sandbox Code Playgroud)
*viewer是指向QmlApplicationViewer的指针,该QmlApplicationViewer派生自QDeclarativeView
我想为Android平台编写一个服务,当前台活动发生变化时会通知该服务.基本上,只有在顶级活动发生变化时,服务才能执行某些任务.有什么方法可以订阅并在发生此类事件时收到通知吗?或者没有可能,服务应不时轮询正在运行的活动列表并检查前台活动是什么?不是更好的解决方案......
我为列表框创建了以下样式,该列表框将在某些文本旁边显示图像:
<Style x:Key="ImageListBoxStyle" TargetType="{x:Type ListBox}">
<Setter Property="SnapsToDevicePixels" Value="true"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
<Setter Property="ScrollViewer.CanContentScroll" Value="True"/>
<Setter Property="ItemContainerStyle">
<Setter.Value>
<!-- Simple ListBoxItem - This is used for each Item in a ListBox. The item's content is placed in the ContentPresenter -->
<Style TargetType="{x:Type ListBoxItem}">
<Setter Property="SnapsToDevicePixels" Value="true"/>
<Setter Property="OverridesDefaultStyle" Value="true"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Grid SnapsToDevicePixels="true">
<Border x:Name="Border">
<Grid Height="40">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Image
x:Name="DisplayImage"
Source="{Binding Path=ThumbnailImage}"
Height="30" …Run Code Online (Sandbox Code Playgroud) 嗨,我已经能够显示我的活动的通知,当用户点击通知时,应用程序重新启动.但是我只是希望它重新出现而不是重启.例如.它是一个Web应用程序,我希望它在用户选择通知时出现在前面..但不刷新网页.我可以捕获这个意图还是我发错了意图?通常,如果我按下主页按钮并单击应用程序图标,应用程序就会出现并且不会刷新/重新启动.所以这就是我想要的行为.有任何想法吗 ?
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager)
getSystemService(ns);
//2.Instantiate the Notification
int icon = R.drawable.notification_icon;
CharSequence tickerText = "My App"; // temp msg on status line
long when = System.currentTimeMillis();
Notification notification = new Notification(icon, tickerText, when);
notification.flags |= Notification.FLAG_ONGOING_EVENT;
//3.Define the Notification's expanded message and Intent:
Context context = getApplicationContext();
CharSequence contentTitle = "Notification";
CharSequence contentText = "My app!"; // message to user
Intent notificationIntent = new Intent(this, HelloAndroid2.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
notificationIntent, 0); …Run Code Online (Sandbox Code Playgroud) notifications android background foreground android-pendingintent
我有一个计时器,当它结束时开始通知.但我想仅在应用程序当前不可见的情况下使用notificationManager发出通知,并在应用程序处于前台时显示计时器结束时显示alertDialog.
我已经尝试过这个:
ActivityManager actMngr = (ActivityManager) ValeoMobileApplication.getContext().getSystemService(Activity.ACTIVITY_SERVICE);
List<RunningAppProcessInfo> runningAppProcesses = actMngr.getRunningAppProcesses();
Tools.log("TimerBroadcastReceiver", "onReceive", "All running processes are listed below :");
for (RunningAppProcessInfo pi : runningAppProcesses) {
//Check pi.processName and do your stuff
//also check pi importance - check if process is in foreground or background
Tools.log("TimerBroadcastReceiver", "onReceive", pi.processName + " importance = "+pi.importance);
if(pi.processName.equalsIgnoreCase("MY_APP_PROCESS_NAME")){
if (pi.importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
isApplicationInForeground = true;
}
}
}
Run Code Online (Sandbox Code Playgroud)
但似乎应用程序是否为前景并不重要.我怎样才能做到这一点?
我有两个Labels StackPanel并Foreground为它们两个设置颜色......第二个显示为黑色,不应该.
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal" Grid.Column="4" Grid.Row="0" Width="Auto" Margin="0,0,20,0">
<Label Content="{lex:LocText CGI, Suffix=:}" Foreground="#FFE0E0E0" FontSize="24" VerticalAlignment="Bottom" Margin="0,0,0,10" HorizontalAlignment="Right" />
<Label Content="{Binding Cgi}" ContentStringFormat="{}{0}%" Foreground="#FFE0E0E0" FontSize="24" VerticalAlignment="Bottom" Margin="0,0,0,10" HorizontalAlignment="Right" />
</StackPanel>
Run Code Online (Sandbox Code Playgroud)
有什么我做错了吗?
我有一种情况,我必须每次从背景到前景初始化一个对象,并且应该使用NSNotificationCenter而不是appdelegate,因为我建立了一个静态库,因此不会有appdelegate,所以请帮助我同样.