omadahealth / LolliPin

A Material design Android pincode library. Supports Fingerprint.
MIT License
1.6k stars 426 forks source link

LockManager.getInstance() on a null object reference #180

Open cgao97 opened 6 years ago

cgao97 commented 6 years ago

Hi guys, I got this message when I tried to add an ignored activity. Below is the code and error message.

LockManager lockManager = LockManager.getInstance(); lockManager.getAppLock().addIgnoredActivity(this.getClass());

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.github.omadahealth.lollipin.lib.managers.AppLock.addIgnoredActivity(java.lang.Class)' on a null object reference

Please help, thank you.

alexkeramidas commented 6 years ago

I think you should do ActivityName.class in there and not this.getClass().

Ideally, the addIgnoredActivity probably should get called in the application class, while setting up lollipin.

So if your activity is called MyActivity the you would do lockManager.getAppLock().addIgnoredActivity(MyActivity.class);