如何知道应用程序何时进入前台?

问题描述 投票:1回答:1

我有一个服务(服务A)和一个应用(应用B)。I want to perform some operations in service A every time app B comes into foreground(visible to user).Is there any Listenercallback that will inform the service A when app B comes into foreground?I know polling method to check the app present on the top of the stack after some interval repeatedly but I want Listenercallback based solution, can anyone suggest?

谢谢

android android-service
1个回答
0
投票

你应该创建 bindService,当其他应用程序调用 bindService onBind 里面 Service 调用,通过意图你就知道是什么app绑定了你的Service,就说明它在力地

© www.soinside.com 2019 - 2024. All rights reserved.