'How to get Callback when other app will Launch in android

everyone I am trying to get a call back in the background in my app when another all-installed app launches.

So I have created Application A other all App is installed like Facebook, Youtube, Gmail, google pay I want to get a call back in my APP which is A in the background when another app will launch.

I am trying to block app usage so suppose when I block Facebook, Gmail, YouTube from APP A then when Facebook, Gmail, or YouTube open I want to start a service that will be notified that Facebook is blocked like this for another app.

Please help me how to apply and how to detect other app call back so that I can start service notified to user Facebook, YouTube is blocked if I selected from APP A Facebook or YouTube is blocked. please suggest some easy way so that I can achieve this

Let me know if it's not clear I will try to explain better.

Thanks



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source