0

I want to count the amount of unlocks, now there are post like this, but they don't explain how to efficiently count unlocks while the app is closed, can I get any code examples? I have tried to use background services, but I don't want a notification constantly displayed while the unlocks are counted.

1 Answers1

0

Register a BroadcastReceiver. The filter you're looking for is ACTION_USER_PRESENT.

In your onReceive() function is triggered, you can load the current number from SharedPreferences, add one and save it back.

RumburaK
  • 1,985
  • 1
  • 21
  • 30