how to know when other app is launched in android

2019-08-06 13:37发布

问题:

Hi friend
I am developing an app in android and i want to know when other application is launched .
for example i want when users run -viber- i running some code in my app . (for example silent the phone or anything)
DRAW ON OTHER APPLICATION can help me or i should to run a service or broadcastReciver for this ?


for examle i want to run this code

AudioManager audio = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
            audio.setRingerMode(0);

when viber is launched .

anyone can help me ?
Thanks.