• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

在前台(顶部)活动(应用程序)发生变化时收到通知

用户头像
it1352
帮助1

问题说明

我想为Android平台编写一个服务,当当前前台活动发生变化时通知.基本上,只有当顶级活动发生变化时,服务才应该执行一些任务.有没有办法订阅并在发生此类事件时收到通知?或者没有可能,服务应该不时轮询正在运行的活动列表并检查前台活动是什么?不是更好的解决方案...

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 有两种方法可以做到这一点.

AFAIK there are two ways to do that.

  1. 启动服务并监控活动堆栈,您可以在此处
  2. 使用无障碍服务,您可以在此处
  3. 找到解决方案
  1. Start a service and monitor the Activity Stack, you might check it here
  2. Use an Accessibility Service, you could find a solution here

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /reply/detail/tanhcfjeek
系列文章
更多 icon
同类精品
更多 icon
继续加载