在其他應用的上層顯示
? ? ? ?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