Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check the broadcast receiver is running or not in android?

Hai is it possible to check the broadcast receiver is currently running or not?if possible how to check it?

like image 599
Mercy Avatar asked Jan 21 '12 13:01

Mercy


2 Answers

You can use dumpsys to help debug this for dynamically registered receivers:

adb shell dumpsys activity broadcasts

Use this in combination with grep and breakpoints in the debugger and you can find if your broadcast is registered at a certain time or not.

This is supposed to help with statically registered receivers, but I haven't used it myself:

adb shell dumpsys package

like image 67
Splaktar Avatar answered Oct 26 '22 05:10

Splaktar


If you want to check it at runtime you can store a global boolean variable and set it to false and inside your onReceive() set it to true and before the onReceive() exit set it back to false . any time you can check this global variable to tell if that broadcast receiver is running or not .

if you mean you want to know if its work or not make a message to the log cat example

    onReceive(){
     Log.d("my broadcast","works");
    }
like image 29
confucius Avatar answered Oct 26 '22 04:10

confucius