0

In my BroadcastReceiver I'm trying to detect a missed call.

So I'm checking if the phone goes from EXTRA_STATE_RINGING to EXTRA_STATE_IDLE. I'm giving each state a fixed value and checking if a particular value is obtained.

However, the values of the variable are not reflected as I expect them to. I've tried using SharedPreferences, but I don't think they can be used inside a BroadcastReceiver. I've tried calling in a different class' object but it's giving me errors.

How can I achieve this? Please help.

Simon Dorociak
  • 33,374
  • 10
  • 68
  • 106
Saturnian
  • 1,686
  • 6
  • 39
  • 65

1 Answers1

2

You should use some king of persistent storage to keep your state variable value between receiving broadcasts. You can use mysql, files or better SharedPreferences. You can easily use SharedPreferences from BroadcastReceiver.

Community
  • 1
  • 1
Leonidos
  • 10,482
  • 2
  • 28
  • 37