How Can I count the number of screen unlocks by a user in Android?
问题 I am currently working on an Android App which informs the number of screen unlocks he/she has done over a day. This example can be seen on stock android devices with API Level P or higher in the feature named Digital Wellbeing. I would like to know how does it work. 回答1: You can add reciever like this in your Activity : private LockScreenStateReceiver mLockScreenStateReceiver; int count = 0; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);