Joke Collection Website - Public benefit messages - Why doesn't my Xiaomi hand automatically fill in the verification code?
Why doesn't my Xiaomi hand automatically fill in the verification code?
Auto-filling is the function of some software, not the function of mobile phone. For example, Alipay can automatically fill in the verification code in the short message in some places where the verification code is entered, provided that your mobile phone has opened the permission to read the short message to Alipay, otherwise Alipay can't get the content of your short message.
In the process of application development, we need to send a verification code to the user to verify the user's identity, but after receiving the SMS verification code, the user needs to leave the current application to check the verification code, and then return to our application to fill in the verification code, which will bring a lot of inconvenience to the user. Applications on android system can read short messages on mobile phones, and we can use this function to get what we want and display it in our input box.
The function we implemented this time needs ContentObserver. When we send a short message to our mobile phone, the mobile phone will automatically call the method specified in the ContentObserver class to inform our application of the changes in the content of the short message. We extract the information from the content and fill it in our input box?
Here I tell you a related design pattern: observer pattern:
Observer pattern is a software design pattern. In this mode, the target object manages all the observer objects that depend on it, and actively sends out notifications when its own state changes. This is usually done by calling the method provided by the observer. This mode is usually used to implement a time processing system.
Observer pattern perfectly separates the observer from the observed object, delimits clear boundaries between modules, and improves the maintainability and reusability of the application.
The observer design pattern defines the one-to-many dependency between objects, so that when the state of an object changes, all the objects that depend on it will be notified and refreshed automatically.
Applied to our example, we first register an observer with our system SMS application during the initial operation of the application, and tell our SMS application that I am your observer, and you will inform me when your own status changes.
Let's look at the basic flow of the observer:
The observer registers himself in the observed subject, and the observed subject stores the observer in the container.
When the observed object changes, all registered observers are obtained from the container, and the changes are notified to the observers.
The observer tells the observer to cancel the observation, and the observer removes the observer from the container.
The purpose of the content observer is to observe (capture) the changes caused by specific URIs in the database, and then do some corresponding processing. It is similar to the trigger in database technology, and it will be triggered when the Uri observed by Content Server changes.
To observe a specific Uri, follow these steps:
1. In order to create our specific ContentOberver derived class, we must overload the parent class constructor and onChange () method to handle the function implementation after the callback.
2. Use context.getContetResolover () to get the ContentResolover object, and then call the registerContentObeserver () method to register the content observer.
3. Because the life cycle of ContentObserver is out of sync with activities and services, it is necessary to manually call unregisterContentObserver () to cancel registration when it is not needed.
- Related articles
- Funny sentences that remind people to eat.
- May Day Blessing Customers 202 1
- How to intercept harassing SMS calls without jailbreaking iPhone5S?
- How to say hello to girls in the morning
- What is the use of the certificate of 2022 Hua Shao Cup Painting and Calligraphy Exhibition?
- Htc mobile phone can't send short messages
- Can Huawei mobile phones send virtual short messages?
- My boyfriend and I have only known each other for a short time. Less than two months. He is in County A and I am in County B, almost 100 kilometers apart. He almost always drives to my place to play..
- Invite guests to dinner
- What do you mean by chatting outside the station?