欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

安卓版微信跳一跳輔助 跳一跳輔助Java代碼

 更新時間:2018年01月05日 11:10:49   作者:Pro47x  
這篇文章主要為大家詳細介紹了安卓版微信跳一跳輔助,簡易版ADB命令式實現(xiàn),具有一定的參考價值,感興趣的小伙伴們可以參考一下

安卓版微信跳一跳輔助,java實現(xiàn),具體內(nèi)容如下

已經(jīng)看到網(wǎng)上有大神用各種方式實現(xiàn)了,我這是屬于簡易版ADB命令式實現(xiàn)。

操作方法

1.光標移動到起始點,點擊FORM
2.光標移動到目標點,點擊TO
3.小人已經(jīng)跳過去了

原理說明

安裝APP,通過設(shè)置起點和目標點位置,獲得彈跳的毫秒數(shù),發(fā)送請求到連接手機的電腦中,電腦執(zhí)行adb命令起跳。

具體實現(xiàn)

本人的測試設(shè)備是Mate9,android版本為7.0,由于在非Root環(huán)境下,普通安卓應(yīng)用并不能通過Runtime.getRuntime().exec()來點擊本應(yīng)用外的區(qū)域,所以將手機直接通過USB調(diào)試模式連接到電腦,在點擊TO按鈕后,

int a = Math.abs(mToX - mFromX);
int b = Math.abs(mToY - mFromY);
double c = Math.sqrt(a * a + b * b);

已知起點和終點的坐標,得到兩條直角邊長度,用勾股定理很容易就求出了斜邊長度,經(jīng)過測試,mate9每ms的彈跳距離是0.75像素,長度除0.75得到time的毫秒數(shù),直接發(fā)起一次GET請求到電腦中發(fā)布的Servlet,然后電腦執(zhí)行Runtime.getRuntime().exec("adb shell input swipe 100 100 100 100 " + time)來控制起跳,一次完美的起跳就完成了。

源代碼

源代碼非常簡單,就直接放在這里了

//寫在安卓APP中的起跳
public class Jump {
private static final String TAG = "Jump";

private Context mContext;
private int mFromX = 0;
private int mFromY = 0;
private int mToX = 0;
private int mToY = 0;

/**
 * 每毫秒的距離
 */
private static final double MS_DISTANCE = 0.75;

private WindowManager wm;
private View mIndicatorView;
private View mIndicator;
private WindowManager.LayoutParams params;
private TextView mTv_time;

public Jump(Context context) {
 mContext = context;
 init();
}

private void init() {
 wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);

 mIndicatorView = LayoutInflater.from(mContext).inflate(R.layout.indicator, null, false);
 mIndicatorView.measure(0, 0);
 mIndicator = mIndicatorView.findViewById(R.id.indicator);
 mTv_time = mIndicatorView.findViewById(R.id.tv_time);
 mIndicatorView.findViewById(R.id.btnForm)
 .setOnClickListener(new View.OnClickListener() {
 @Override
 public void onClick(View v) {
  setForm();
 }
 });
 mIndicatorView.findViewById(R.id.btnTo)
 .setOnClickListener(new View.OnClickListener() {
 @Override
 public void onClick(View v) {
  setTo();
 }
 });


 mIndicatorView.setOnTouchListener(new View.OnTouchListener() {
 int startX;
 int startY;

 @Override
 public boolean onTouch(View v, MotionEvent event) {
 switch (event.getAction()) {
 case MotionEvent.ACTION_DOWN:
  startX = (int) event.getRawX();
  startY = (int) event.getRawY();
  break;

 case MotionEvent.ACTION_MOVE:
  int newX = (int) event.getRawX();
  int newY = (int) event.getRawY();
  int dx = newX - startX;
  int dy = newY - startY;
  params.x += dx;
  params.y += dy;
  wm.updateViewLayout(mIndicatorView, params);
  startX = (int) event.getRawX();
  startY = (int) event.getRawY();
  break;

 default:
  break;
 }
 return true;
 }
 });
 params = new WindowManager.LayoutParams();
 params.height = WindowManager.LayoutParams.WRAP_CONTENT;
 params.width = WindowManager.LayoutParams.WRAP_CONTENT;
 params.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
 | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
 params.format = PixelFormat.TRANSLUCENT;
 params.gravity = Gravity.TOP + Gravity.LEFT;
 params.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
 wm.addView(mIndicatorView, params);
}


public void setForm() {
 int[] mLocation = new int[2];
 mIndicator.getLocationOnScreen(mLocation);
 int wOffset = mIndicator.getMeasuredWidth() / 2;
 int hOffset = mIndicator.getMeasuredHeight() / 2;
 mFromX = mLocation[0] + wOffset;
 mFromY = mLocation[1] + hOffset;
}

public void setTo() {
 int[] mLocation = new int[2];
 mIndicator.getLocationOnScreen(mLocation);
 int wOffset = mIndicator.getMeasuredWidth() / 2;
 int hOffset = mIndicator.getMeasuredHeight() / 2;
 mToX = mLocation[0] + wOffset;
 mToY = mLocation[1] + hOffset;

 int a = Math.abs(mToX - mFromX);
 int b = Math.abs(mToY - mFromY);
 double c = Math.sqrt(a * a + b * b);
 final int time = (int) (c / MS_DISTANCE);
 mTv_time.setText(String.valueOf(time));

 mFromX = 0;
 mFromY = 0;
 mToX = 0;
 mToY = 0;

 new Thread(new Runnable() {
 @Override
 public void run() {
 requestGet(time);
 }
 }).start();
}

private void requestGet(int time) {
 try {
 StringBuilder requestUrl = new StringBuilder("http://192.168.1.140:8080/jump/JumpTime").append("?").append("time=").append(time);
 // 新建一個URL對象
 URL url = new URL(requestUrl.toString());
 // 打開一個HttpURLConnection連接
 HttpURLConnection urlConn = (HttpURLConnection) url.openConnection();
 // 設(shè)置連接主機超時時間
 urlConn.setConnectTimeout(5 * 1000);
 //設(shè)置從主機讀取數(shù)據(jù)超時
 urlConn.setReadTimeout(5 * 1000);
 // 設(shè)置是否使用緩存 默認是true
 urlConn.setUseCaches(true);
 // 設(shè)置為Post請求
 urlConn.setRequestMethod("GET");
 //urlConn設(shè)置請求頭信息
 //設(shè)置請求中的媒體類型信息。
 urlConn.setRequestProperty("Content-Type", "application/json");
 //設(shè)置客戶端與服務(wù)連接類型
 urlConn.addRequestProperty("Connection", "Keep-Alive");
 // 開始連接
 urlConn.connect();
 // 判斷請求是否成功
 if (urlConn.getResponseCode() == 200) {
 // 獲取返回的數(shù)據(jù)
 Log.e(TAG, "Get方式請求成功,result--->");
 } else {
 Log.e(TAG, "Get方式請求失敗");
 Log.e(TAG, urlConn.getResponseMessage());
 }
 // 關(guān)閉連接
 urlConn.disconnect();
 } catch (Exception e) {
 Log.e(TAG, e.toString());
 }
}
}

//標靶的布局文件
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="150dp">

<RelativeLayout
 android:layout_width="100dp"
 android:layout_height="wrap_content">

 <TextView
 android:id="@+id/tv_time"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_centerHorizontal="true"/>

 <RelativeLayout
 android:id="@+id/rl"
 android:layout_width="100dp"
 android:layout_height="100dp"
 android:layout_below="@id/tv_time">

 <View
 android:layout_width="match_parent"
 android:layout_height="1dp"
 android:layout_centerVertical="true"
 android:background="@android:color/black"/>

 <View
 android:layout_width="1dp"
 android:layout_height="match_parent"
 android:layout_centerHorizontal="true"
 android:background="@android:color/black"/>

 <View
 android:id="@+id/indicator"
 android:layout_width="30dp"
 android:layout_height="30dp"
 android:layout_centerInParent="true"
 android:background="@drawable/mid"/>

 </RelativeLayout>

 <Button
 android:id="@+id/btnForm"
 android:layout_width="50dp"
 android:layout_height="wrap_content"
 android:layout_below="@id/rl"
 android:onClick="setForm"
 android:text="form"
 android:textSize="8sp"/>

 <Button
 android:id="@+id/btnTo"
 android:layout_width="50dp"
 android:layout_height="wrap_content"
 android:layout_alignParentRight="true"
 android:layout_below="@id/rl"
 android:onClick="setTo"
 android:text="to"
 android:textSize="8sp"/>
</RelativeLayout>
</FrameLayout>

//Servlet文件
public class Jump extends HttpServlet {

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
 int time = Integer.parseInt(req.getParameter("time"));
 Runtime.getRuntime().exec("adb shell input swipe 100 100 100 100 " + time);
}
}

以上就是此Java版跳一跳輔助的核心內(nèi)容,從此制霸排行榜不是夢φ(>ω<*)--->(告訴一個秘密:跳太多分數(shù)會被直接刪除的喲  ̄へ ̄)

更多內(nèi)容大家可以參考專題《微信跳一跳》進行學(xué)習(xí)。

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • android自定義AlertDialog對話框

    android自定義AlertDialog對話框

    這篇文章主要為大家詳細介紹了android自定義AlertDialog的相關(guān)資料,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-01-01
  • 圖解Eclipse在線安裝ADT插件過程

    圖解Eclipse在線安裝ADT插件過程

    這篇文章主要以圖解的方式為大家分享了Eclipse在線安裝ADT插件過程,需要的朋友可以參考下
    2015-12-12
  • 解決Android TabLayout 在寬屏幕上tab不能平均分配的問題

    解決Android TabLayout 在寬屏幕上tab不能平均分配的問題

    這篇文章主要介紹了解決Android TabLayout 在寬屏幕上tab不能平均分配的問題,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-08-08
  • Android自定義View圖片按Path運動和旋轉(zhuǎn)

    Android自定義View圖片按Path運動和旋轉(zhuǎn)

    這篇文章主要為大家詳細介紹了Android自定義View圖片按Path運動和旋轉(zhuǎn),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-01-01
  • Android仿支付寶支付密碼輸入框

    Android仿支付寶支付密碼輸入框

    這篇文章主要為大家詳細介紹了Android仿支付寶支付密碼輸入框的實現(xiàn)代碼,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2016-11-11
  • Android實現(xiàn)圖片雙指縮放

    Android實現(xiàn)圖片雙指縮放

    這篇文章主要為大家詳細介紹了Android實現(xiàn)圖片雙指縮放,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-11-11
  • Android實現(xiàn)視頻彈幕功能

    Android實現(xiàn)視頻彈幕功能

    這篇文章主要為大家詳細介紹了Android實現(xiàn)視頻彈幕功能,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2019-11-11
  • Android 異步加載圖片分析總結(jié)

    Android 異步加載圖片分析總結(jié)

    研究了android從網(wǎng)絡(luò)上異步加載圖像,現(xiàn)總結(jié)如下,感興趣的朋友可以了解下哈
    2013-06-06
  • Android開發(fā)之文件操作詳解

    Android開發(fā)之文件操作詳解

    這篇文章主要介紹了Android開發(fā)之文件操作,結(jié)合實例形式分析了Android開發(fā)中文件操作的步驟及布局、功能等實現(xiàn)技巧,需要的朋友可以參考下
    2017-07-07
  • Android打造屬于自己的時間鐘表

    Android打造屬于自己的時間鐘表

    這篇文章主要為大家詳細介紹了Android自定義一個屬于自己的時間鐘表的相關(guān)資料,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2016-12-12

最新評論