Android realizes Alipay gesture password function

Today, we share with you the Android implementation of Alipay gesture password. It is very common. Like WeChat now pays, Alipay must set up 4 bit PIN code when it is paid by Alipay, then input the PIN code immediately to call the payment interface to pay. There is no doubt that the security problem will not feel that the mobile phone is taken away without knowing the whereabouts of its net cash. This is also a normal security logic problem.

OK, let's look at the specific implementation:

At the entrance, a few simple buttons are displayed on the startup page. The code is as follows:

Let's look at the operation of the four buttons. The code is as follows:

We can see that custompinactivity and lockedcompatactivity will be posted below. The previous operation is roughly like this. Set different putextra values for each button. The first setting button uses the startactivityforresult startup page, because the password is stored in the applocation after setting, and when you get the request code and return to the main page, toast will be made "Start pin code", but if you want to change and verify the password, you must set the password first. This is a very normal logic. I'll post the application first. It's relatively simple. A few codes:

Lockmanager is a library using netizens. Let me post custompinactivity:

Customdialog also uses a third party instead of the alertdialog provided by the system, because it is too ugly. I think those who pursue perfection are ugly. The view for setting the password is user-defined, including the keyboard.

The lockedcompatactivity class is as follows:

This class is a page that can only be accessed after entering the correct pin code, so that you can operate what you want to operate on this page, such as calling the payment interface to directly execute the payment operation. This is also a good example. The wrong pin code vibrates the keyboard.

Briefly describe the following main implementation codes to see the overall effect:

Finally, the source code is attached. Thank you for taking it! Download address

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>