Search code examples
androidbroadcastreceiverandroid-broadcastreceiver

how can i register TIME_TICK event broadcast receiver for android app even if app is running or not


i want to fire some event when system time matches the time stored in my database.I tried out this by using TIME_TICK broadcast receiver.when this receiver receive broadcast, i match my database entries with system time...but problem is that i can register this broadcast receiver from activity only...can't register from manifest file.so, when i close my app or remove it from recent apps list, this broadcast receiver stops working. I refer the documentation that says that "TIME_TICK can only register from activity , not from manifest file". I also tried to find solution for my problem on stackoverflow and on google but i can't found proper answer. so, if you know how to solve it then reply my question and thanks in advance.


Solution

  • i want to fire some event when system time matches the time stored in my database

    Use AlarmManager.

    how can i register TIME_TICK event broadcast receiver for android app even if app is running or not

    That is not possible, as it is incredibly inefficient.