Previous useJavaCallMonkeyrunner(Http://www.cnblogs.com/nuliniaoboke/archive/2012/11/23/2784385.html) left a problem, that is, the last use of a lower version4To solve the problem, use a later versionJarHow to call a packageMonkeyrunnerWhat about it?
After a friend prompts me that the method of the higher version has changed, I searched the required classes online according to his prompt. After the test passed, summary of this supplementary article.
Last time I usedAndroid SDK toolsPathLibInside4Packages:Ddmlib. jar, guavalib. jar, monkeyrunner. jar, sdklib. jar.In the updated version, another package must be added:Chimpchat. Jar,Monkerunner. JarThis package is not required. In addition, earlier versions useAdbmonkeydeviceImplementationImonkeydeviceIn the later version, these two classes are not available.AdbchimpdeviceAndIchimpdevice. ViewAdbchimpdevice( Http://code.google.com/p/aster/source/browse/src/com/android/chimpchat/adb/AdbChimpDevice.java? R = 967f7f8cd6249c69e00c6de7ff1b55bd0f51d311 ) AndIchimpdevice( Http://code.google.com/p/aster/source/browse/src/com/android/chimpchat/core/IChimpDevice.java? R = 967f7f8cd6249c69e00c6de7ff1b55bd0f51d311 ) These two classes are not difficult to find in the official source code,AdbchimpdeviceImplementedIchimpdeviceThis interface, but the connection method still passesAdbbackend, ThroughADBConnect to the simulator or the real machine. JustDeviceThe parent class of has changed. We can see the differences between the two by slightly changing the test classes below:
Import Java. util. arraylist; Import Java. util. collection; Import Java. util. hashmap; Import Com. Android. chimpchat. ADB. adbbackend; Import Com. Android. chimpchat. ADB. adbchimpdevice; Public Class Testnewmonkeyrunner { /** * @ Param ARGs */ // Changes Private Static Adbchimpdevice device; Private Static Adbbackend ADB; Public Static Void Main (string [] ARGs ){ // Todo auto-generated method stub If (ADB = Null ) {ADB = New Adbbackend (); // The parameters are the custom connection wait time and device ID respectively. // Note the ADB type. Device = (adbchimpdevice) ADB. waitforconnection (8000, "msm8225qrd5" );} // Add start permission String action = "android. Intent. Action. Main" ; Collection <String> categories = New Arraylist <string> (); Categories. Add ( "Android. Intent. Category. launcher" ); // Start the main interface to be tested Device. startactivity ( Null , Action, Null , Null , Categories, New Hashmap <string, Object> (), "cn.com. fetion/. Android. UI. Activities. startactivity", 0 ); // Click a Coordinate // Touch method slightly changed Device. Touch (202,258 , Com. Android. chimpchat. Core. touchpresstype. down_and_up );}}
We can see from the above that there are not many changes between the high version and the low version. As long as you connect to the device, you can check the source code or rewrite some common methods. The comments in the source code are very detailed, such as the startactivity method in the ichimpdevice interface class:
Void Startactivity (@ nullable string Uri, @ nullable string action, @ nullable string data, @ nullable string mimetype, Collection <String> categories, Map <string, Object> Extras, @ nullable string component, Int Flags ); /** * Send a broadcast intent to the device .** @ Param Uri the URI for the intent * @ Param Action The Action for the intent * @ Param Data the data URI for the intent * @ Param Mimetype the MIME type for the intent * @ Param Categories the category names for the intent * @ Param Extras the extras to add to the intent * @ Param Component the component of the intent * @ Param Flags the flags for the intent */
The parameters are clearly explained. Therefore, we recommend that youJavaCallMonkeyrunnerDon't forget the best source code resource.
Launch address: http://www.eoeandroid.com/thread-232303-1-1.htmlcatch up with the tide of windows8applications and be the first developer of Microsoft
Http://wp.eoe.cn/thread-9325-1-1.html