如何检测,如果目前家庭活动是ActivityStack顶部 [英] How to detect if Home Activity is currently on the top of ActivityStack

查看:94
本文介绍了如何检测,如果目前家庭活动是ActivityStack顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要检测当前的前景活动从后台服务。

I want to detect current foreground activity from a background service.

我特别想知道,如果目前家庭活动是在Android活动堆栈的顶部与否。

Particularly I want to know if Home activity is currently on the top of android activity stack or not.

使用的情况是这样的:如果家庭活动是在前台(即用户没有使用任何其他应用程序),我需要显示在后台服务的一些事件警告对话框。但是,如果家庭的活动是不是在堆栈顶部(即用户使用其他应用程序),我应该显示状态栏的通知上的服务的一些事件。

Use case is something like: If home activity is on foreground (i.e User is not using any other application) I need to show a alert dialog on some event in background service. But if, Home activity is not on top of stack (i.e. user is using some other application), i am supposed to show a notification in status bar on some event in service.

有什么方法来检测当前的前台活动?

Is there any way to detect current foreground activity?

推荐答案

请参阅本 这里

在这里您可以找到前台的活动,然后与家庭package.Its比较其包可能是android.home

Here you can find the foreground Activity then compare its package with the home package.Its may be android.home

这篇关于如何检测,如果目前家庭活动是ActivityStack顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆