Android 自動化操作,輔助功能無障礙,在其他應用的上層顯示

在其他應用的上層顯示

? ? ? ?1、獲取權限

<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

?2、創(chuàng)建服務 用來展示懸浮窗

?3、啟動懸浮窗

輔助功能無障礙

<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

? ? ? ? 給Service設置無障礙模式

<service

? ? android:name=".services.ScrollService"

? ? android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">

? ? <intent-filter>

? ? ? ? <action android:name="android.accessibilityservice.AccessibilityService" />

? ? </intent-filter>

? ? <meta-data

? ? ? ? android:name="android.accessibilityservice"

? ? ? ? android:resource="@xml/accessibility" />

</service>

ScrollService需要繼承AccessibilityService

點擊 滑動 返回操作

@RequiresApi(Build.VERSION_CODES.N)

protected void autoSlideView(float startX, float startY, float endX, float endY) {

? ? android.graphics.Path path = new android.graphics.Path();

? ? path.moveTo(startX, startY);

? ? path.lineTo(endX, endY);

? ? GestureDescription gestureDescription = new GestureDescription.Builder()

? ? ? ? ? ? .addStroke(new GestureDescription.StrokeDescription(path, 0, 500))

? ? ? ? ? ? .build();

? ? dispatchGesture(gestureDescription, new GestureResultCallback() {

? ? ? ? @Override

? ? ? ? public void onCompleted(GestureDescription gestureDescription) {

? ? ? ? ? ? super.onCompleted(gestureDescription);

? ? ? ? }

? ? ? ? @Override

? ? ? ? public void onCancelled(GestureDescription gestureDescription) {

? ? ? ? ? ? super.onCancelled(gestureDescription);

? ? ? ? }

? ? }, null);

}

@RequiresApi(Build.VERSION_CODES.N)

protected void autoClickView(float startX, float startY) {

? ? android.graphics.Path path = new android.graphics.Path();

? ? path.moveTo(startX, startY);

? ? GestureDescription gestureDescription = new GestureDescription.Builder()

? ? ? ? ? ? .addStroke(new GestureDescription.StrokeDescription(path, 0, 5))

? ? ? ? ? ? .build();

? ? dispatchGesture(gestureDescription, new GestureResultCallback() {

? ? ? ? @Override

? ? ? ? public void onCompleted(GestureDescription gestureDescription) {

? ? ? ? ? ? super.onCompleted(gestureDescription);

? ? ? ? }

? ? ? ? @Override

? ? ? ? public void onCancelled(GestureDescription gestureDescription) {

? ? ? ? ? ? super.onCancelled(gestureDescription);

? ? ? ? }

? ? }, null);

}

protected void autoBackView() {

? ? performGlobalAction(GLOBAL_ACTION_BACK);

}

Apk資源:

http://d.maps9.com/52f6

https://iaoqbthyohbschdxnvya.supabase.co/storage/v1/object/public/userapk/coupons.apk

?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容