編輯:關於Android編程
1. Android Monkey 實現操作流程:
准備:在eclipse裡安裝Phyon插件,可以選擇在線安裝,也可以下載zip解壓後放在eclipse安裝目錄的dropins下,如 : /personal/software/android_developtools/adt-bundle-mac-x86_64-20130522/eclipse/dropins/PyDev 2.8.2
插件准備就緒就重啟eclipse,檢驗PyDev是否正常工作,然後開始MonkeyRunner測試:
第一步:
gufeitekiMacBook-Pro:~ gufei$ cd /personal/software/android_developtools/adt-bundle-mac-x86_64-20130522/sdk/tools
第二步:
gufeitekiMacBook-Pro:tools gufei$ ls Jetemulator-x86monkeyrunner NOTICE.txtemulator64-armproguard adb_has_moved.txtemulator64-mipssource.properties androidemulator64-x86sqlite3 antetc1toolsupport appshierarchyviewersystrace ddmshprof-convtemplates dmtracedumpjobbtraceview draw9patchlibuiautomatorviewer emulatorlintzipalign emulator-armmksdcard emulator-mipsmonitor
第三步:
gufeitekiMacBook-Pro:tools gufei$ ./emulator -avd android_480_800 emulator: emulator window was out of view and was recentered
然後重新打開一個新的命令窗口
第四步:
gufeitekiMacBook-Pro:~ gufei$ cd /personal/software/android_developtools/adt-bundle-mac-x86_64-20130522/sdk/tools gufeitekiMacBook-Pro:tools gufei$ ./monkeyrunner Jython 2.5.3 (2.5:c56500f08d34+, Aug 13 2012, 14:54:35) [Java HotSpot(TM) 64-Bit Server VM (Apple Inc.)] on java1.6.0_51
第五步:
from com.android.monkeyrunner import MonkeyRunner,MonkeyDevice,MonkeyImage
第六步:
android_480_800.installPackage("/personal/developer/android/project/UnionPay/Android/UPClient_3_0_lib/bin/UPClient_3_0_lib.apk")
ps:裡面的5指等待5s,可以不寫,代表永遠等待,也可以自己自定義時間。
第七步:
android_480_800.installPackage("/personal/developer/android/project/UnionPay/Android/UPClient_3_0_lib/bin/UPClient_3_0_lib.apk")
安裝成功後命令窗口打印出:True
第八步:
android_480_800.startActivity(component="com.unionpay/com.unionpay.client3.UPActivityWelcome")
觀察模擬器是否已經打開該界面
第九步:(自己模擬點擊坐標)
android_480_800.touch(386.0,399.0,android_480_800.DOWN_AND_UP) android_480_800.touch(35.0,146.0,android_480_800.DOWN_AND_UP) android_480_800.touch(5.0,609.0,android_480_800.DOWN_AND_UP) android_480_800.touch(44.0,569.0,android_480_800.DOWN_AND_UP) android_480_800.touch(-1.0,-1.0,android_480_800.DOWN_AND_UP) android_480_800.touch(467.0,759.0,android_480_800.DOWN_AND_UP) android_480_800.touch(457.0,726.0,android_480_800.DOWN_AND_UP) android_480_800.touch(265.0,776.0,android_480_800.DOWN_AND_UP) android_480_800.touch(271.0,787.0,android_480_800.DOWN_AND_UP) android_480_800.touch(176.0,278.0,android_480_800.DOWN_AND_UP) android_480_800.touch(187.0,257.0,android_480_800.DOWN_AND_UP) result= android_480_800.takeSnapshot() result.writeToFile("/Users/gufei/Downloads/MonkeyRunnerShoot.png") print("OK!")
偶然間發現了Android.inputmethodservice.Keyboard類,即android可以自定義鍵盤類,做了一個簡單例子供大家參考。效果如下:先看界面布局
1.介紹看下效果圖,gif錄的有些卡頓,在真機上運行效果很好。2.實現很有意思的一個效果,原理其實很簡單,就是通過監聽ScrollView在Y軸的滑動距離,然後在代碼中動
PowerManagerService負責Android系統中電源管理方面的工作,為了簡便我們在下文中將其簡稱為PMS。我們先大致了解一下PMS在Android中的整體結
JSON(JavaScript Object Notation)是一種輕量級的數據交換格式,采用完全獨立於語言的文本格式,為Web應用開發提供了一種理想的數據交換格式。