天天看點

Java微信如何自動添加好友,微信自動加好友 模拟位置

周圍朋友有做代購的想要自定義位置,并且能夠搜尋附近的人自動打招呼的功能。

原理其實比較簡單,主要是通過地圖SDK(百度,或者高德)擷取對應位置經緯度,然後設定成目前位置(虛拟位置),在通過自動化測試工具自動去操作微信。

需求:

1 自定義目前位置

2 微信搜尋附近的人,自動打招呼

3 可以自定義消息内容

需要的知識點:

1百度地圖SDK 擷取位置 設定目前位置

2robotium自動化測試庫

3 城市位置資料庫

程式架構:

1啟動界面--選擇城市---啟動微信--自動化操作

技術預研

1 模拟位置

2 結合百度地圖或者城市資料庫進行位置選擇

3 自動化操作流程

4 如何啟動微信 進行中

1模拟位置已經通過測試

2百度地圖SDK以前做,擷取經緯度坐标 通過

3啟動微信startActivity(AcitivyLanchMM.this.getPackageManager().getLaunchIntentForPackage("com.tencent.mm"));

4自動化操作正在進行。。。

遇到的問題:

Test run failed: Permission Denial: starting instrumentation ComponentInfo{com.jayway.test/android.test.InstrumentationTestRunner} from pid=27322, uid=27322 not allowed because package com.jayway.test does not have a signature matching the target com.tencent.mm

解決方法:

使用re-sign.jar 重簽名apk

使用adb install xx.apk進行安裝

注意:在自己的應用中啟動自動測試時,使用 String cmd = "adb shell am instrument -e class com.robotium.test.NotePadTest -w com.jayway.test/android.test.InstrumentationTestRunner";

Runtime.getRuntime().exec(cmd)打開測試用例 需要有root權限(),在沒有root的情況下可以使用startInstrumentation(new ComponentName("com.jayway.test", "android.test.InstrumentationTestRunner"), null, null); 打開 參考連結點選打開連結

自動化操作可以參考Demo:點選打開連結

完整程式:

1 GPS(這個是模拟位置的,經緯度可以通過百度地圖擷取到)

2 WxRobot(微信6.0以上自動打招呼)

啟動GPS 然後再啟動WxRobot 添加好友吧!