0

Is it possible that If I place some part of the code from my Activity in Broadcast and then even if the activity is not running the broadcasted piece of code will continue to work?If yes any reference to it plz? To b specific I've facebook activity that retrieves notifications on button click.I want that get notification method to b in a broadcast so that every time notification arrives it generates alert.Can provide the code aswel.. Kindly help

Nauman Aslam
  • 299
  • 3
  • 14

2 Answers2

0

Is it possible that If I place some part of the code from my Activity in Broadcast and then even if the activity is not running the broadcasted piece of code will continue to work?

No, it is not possible that your activity is not running and you defined your broadcast in the activity and you still want the broadcast to run that is within that activity.

sjain
  • 23,126
  • 28
  • 107
  • 185
0

Add the BroadCast Receiver in a Service class. register and unregister this broadcast receiver from onCreate() and onDestroy() methods respectively of Service class.

Sunny Garg
  • 1,073
  • 1
  • 6
  • 13
  • i.e I've to create another class that extends service and place my code in there and on success it should sendBroadcast that my activity will receive?rite direction? – Nauman Aslam Apr 16 '14 at 10:40
  • You can this way. 1. On success it should send an notification to device. 2. Then clicking on this notification you can navigate to your activity. – Sunny Garg Apr 16 '14 at 10:43