5 years ago (2015-10-02)  Algorithm language Software development |   First to comment  16 
post score 0 times, average 0.0
[Slideup] Catalog

In the Android development process, the same operation is often performed in different environments. Of course, it is easy to think of the method is to extract the same operation in a function, only in the implementation of the same or similar operations Need to run the function then.If the function being executed is in a different class or activity (of course the activity is also a class), we only need to define the access level of the function as public static. The above believe that even the most basic developers know that it seems that the very guests have nothing to say.When calling a public static method b of another class B in a class A, if method b uses other variables of class B, such as c, d, f, etc., when modifying method b is a public static class B The variables c, d, and f are also changed to static variables, because static methods do not allow non-static variables to be called. This change is often triggered by the whole body. Sometimes we happen to encounter this situation. The operation performed in class B is the operation performed by clicking one of the buttons of the activity.For example, when we develop an Android app, we often have an application update function. When entering MainActivity, the app often performs the check update operation in the background without knowing it. At the same time, we can allow users to use the “About” page of the app. Manually click the button and then "Check for Updates".In fact, the execution of these two check updates is exactly the same, if you repeatedly write in the two Activities will be very troublesome.At this time, we might as well try to simulate the click of the Android button and implement the code to simulate the human hand click the button.


Calling performClick() to raise a Click event


This article has been printed on copyright and is protected by copyright laws. It must not be reproduced without permission.If you need to reprint, please contact the author or visit the copyright to obtain the authorization. If you feel that this article is useful to you, you can click the "Sponsoring Author" below to call the author!

Reprinted Note Source: Baiyuan's Blog>>https://wangbaiyuan.cn/en/click-on-button-android-simulation-2.html

Post comment


No Comment


Forget password?