Q:

How to use listner inside a BroadCastRecievever?

I have to display number of times device is unlocked with a textView which is inside my Activity.
I am storing the unlock frequency in Prefrences with BroadCast Reciever USER_ACTIVE onReciever().
I want to update the Activity textView everyTime i recieve the User_Active broadcast.
Any leads?  

A:

Simple three steps:

Create a runtime broadcast receiver with your own action(Ex: UPDATED_TEXT_PREFERENCES).
Register/unregister for broadcast  in onStart() and onStop()
On your USER_ACTIVE onReciever(). send a broadcast with the own action you have created(Ex: UPDATED_TEXT_PREFERENCES)
On your activity onReceive you can update your textview.

Comment below for any doubts.

