I have a Service running and i want the service to be informed when certain apps get opened and closed / stopped. I think the start of an App is possible to listen on, but what about the start/resume and the stop ?
Asked
Active
Viewed 264 times
1
-
I believe this is impossible? It would be a breach of security on the device. – Alexander Craggs Sep 02 '14 at 12:38
-
from logs may be u can figure out ..by adb logcat | grep "ActivityManager" actually tell which is current activity in android.. – KOTIOS Sep 02 '14 at 12:43
1 Answers
1
Perhaps check the foreground application?
See this SO thread: Determining the current foreground application from a background task or service
When the application changes, you know that the app has been stopped/paused.
-
this is already really nice, though i have to check manually instead of listening, but if there is no other solution to it, this will be it – AdrianoCelentano Sep 02 '14 at 12:52
-
I don't think there's any other way to do it, as it would be a security issue to be able to read other apps state. – dthomasen Sep 02 '14 at 12:54