-1

I have such a problem, it is necessary if you run any application to output Toast with the text "some application to run," and when closed by show again Toast with text "some application is completed."

For example launched Play Market, and in my app Toast with the text "Play Market is run."

I have no idea how it implemented, it seems necessary to use the Service Broadcast. Please tell me how to implement?

Andrii Omelchenko
  • 13,183
  • 12
  • 43
  • 79
No Name
  • 741
  • 8
  • 18
  • 1
    You want code which monitors the user as they use their device and can detect all the applications they use? That sounds... odd. – takendarkk Dec 02 '16 at 21:24
  • most likely not in an easy way you'd like it to be, whether app-A is running/closing is not exposed to app-B unless app-A itself implements a broadcast... unless you want to continually brute scan active running processes and continually compare. – TWL Dec 02 '16 at 22:11
  • "it is necessary" - why? According to who? – OneCricketeer Dec 05 '16 at 02:14
  • 1
    Duplicate anyway. http://stackoverflow.com/questions/3290936/android-detect-when-other-apps-are-launched and http://stackoverflow.com/questions/22500959/detect-when-other-application-opened-or-launched – OneCricketeer Dec 05 '16 at 02:15
  • Simply adding a bounty to your question will not solve your problems. See the links cricket_007 has provided. Do some research – denvercoder9 Dec 05 '16 at 10:50
  • As of Android 5.0, doing this in a reliable way will be difficult, if not impossible, for privacy and security reasons. – CommonsWare Dec 05 '16 at 14:35
  • @CommonsWare is this a duplicate of those suggested? – Jon Clements Dec 05 '16 at 14:39
  • @JonClements: The other questions suggested by cricket_007 are on the same topic, IMHO. – CommonsWare Dec 05 '16 at 15:16
  • @CommonsWare were the bounty removed - would you be confident enough it's already solved elsewhere? – Jon Clements Dec 05 '16 at 15:18
  • @JonClements: Not for a conventional definition of "solved", IMHO. What is requested is impractical on modern versions of Android. The closest answer out of all of those is [this one](http://stackoverflow.com/a/32424365/115145), but since `UsageStatsManager` does not offer real-time data, it cannot be used to solve the problem expressed in this particular question. – CommonsWare Dec 05 '16 at 15:24
  • @CommonsWare okay then - is this question answerable in its current form or should it be closed - if so for what reason? – Jon Clements Dec 05 '16 at 15:33

1 Answers1

0

To the best of my knowledge, outside of possible security flaws, there is no reliable way to implement what you want on Android 5.0 and higher, for privacy and security reasons.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491